You are not logged in.

#1 2009-03-01 20:29:04

blackhole
Member
From: Karlsruhe, Germany
Registered: 2008-12-14
Posts: 148
Website

How to change swap and home partition after installation

Hi guys,

I've been playing with Arch for a couple of weeks now and finally feel comfortable enough to move my whole IT identity from my Windows XP partition to the brave new Linux world. That's why I want to reorganize my partition table.

Here's how it looks like at the moment:

schorsch@archie:~$ sudo fdisk -l /dev/sda

Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x41ab2316

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         261     2096451   de  Dell Utility
/dev/sda2   *         262        4085    30716280    7  HPFS/NTFS
/dev/sda3            4086        7397    26603640    f  W95 Ext'd (LBA)
/dev/sda4            7398        9729    18731790   83  Linux
/dev/sda5            4086        7273    25607578+   7  HPFS/NTFS
/dev/sda6            7274        7397      995998+  82  Linux swap / Solaris
schorsch@archie:~$

Explanation:
sda1: Windows C-drive
sda2: Dell Stuff which nobody really needs
sda3: Extended partition container
sda4: My Linux root partition
sda5: Windows D-drive
sda6: My Linux swap partition

Now, I want to remove sda5 and sda6 and replace them by a bigger swap partition (due to suspend2disk and RAM size), a home partition and a backup partition for my data.

So ideally it would look like this:
sda1: Windows C-drive
sda2: Dell Stuff which nobody really needs
sda3: Extended partition container
sda4: My Linux root partition
sda5: Linux home
sda6: Linux backup
sda7: Linux swap

At the moment my /etc/fstab looks like this:

# /etc/fstab: static file system information
#
# <file system>        <dir>         <type>    <options>          <dump> <pass>
none                   /dev/pts      devpts    defaults            0      0
none                   /dev/shm      tmpfs     defaults            0      0


/dev/cdrom /media/cdrom   auto    ro,user,noauto,unhide   0      0
/dev/dvd /media/dvd   auto    ro,user,noauto,unhide   0      0
#/dev/sdb1 /mnt/usbstick auto rw,user,noauto,exec,async 0 0

UUID=4aef5a26-fdbe-4a48-a058-221a119f57b2 / ext3 defaults 0 1
UUID=b4f7e950-c91b-40fd-9104-6963be6c5149 swap swap defaults 0 0

I know how to handle the partitioning with Gparted Live CD, however I was wondering how to change my swap partition and home mounting point in the system.
Here my questions:

1.) Do I have to manually set a UUID for my new swap partition or is this automatically done by GParted?

2.) Do I only have to add my new swap partition in /etc/fstab or do I have to modify any other system files?

3.) What's the best way to change my /home directory to another partition? Can I just log in as root, do a "cp -R /home /mnt/mynewhome", delete the old /home (which is on the root partition at the moment) and then mount the new partition under /home? Would that work or should I do the whole thing from a LiveCD? Do I have to modify any other system files?

4.) How would the fstab-entry for my home partition look like?

Thanks a lot in advance,
a future Linux user ^^


Coming closer and closer to the ultimate goal: replacing boring old Windows XP desktop with shiny new Arch KDE 4 desktop. ^^
Already registered? Your vote counts!

Offline

#2 2009-03-01 21:44:33

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: How to change swap and home partition after installation

Welcome to Linux smile

blackhole wrote:

1.) Do I have to manually set a UUID for my new swap partition or is this automatically done by GParted?

It is automatically generated and written when the swap partition is created.

blackhole wrote:

2.) Do I only have to add my new swap partition in /etc/fstab or do I have to modify any other system files?

Adding it to fstab is sufficient smile

blackhole wrote:

3.) What's the best way to change my /home directory to another partition? Can I just log in as root, do a "cp -R /home /mnt/mynewhome", delete the old /home (which is on the root partition at the moment) and then mount the new partition under /home? Would that work or should I do the whole thing from a LiveCD? Do I have to modify any other system files?

If you login as root, you should be fine to do it the first way you've described. If you've got the diskspace, rename the old home just in case until you've rebooted and tested it's all working wink
Modifying fstab to mount the new home partition is sufficient

blackhole wrote:

4.) How would the fstab-entry for my home partition look like?

/dev/sda5    /home      ext4     defaults     0  0

Replace ext4 with whatever filesystem you choose

Offline

#3 2009-03-01 21:52:58

konni
Member
From: berlin
Registered: 2008-09-25
Posts: 99

Re: How to change swap and home partition after installation

1) the uuid gets set automatically when you create a partition and if i remember correctly stays the same unless you delete the partition (moving, resizing etc allowed).
you can find the uuid for a device by doing 'ls -l /dev/disk/by-uuid'

2) you have to set it in /etc/fstab and, for hibernate support in /boot/grub/menu.lst like

kernel /vmlinuz26 root=/dev/sda1 resume=/dev/sda3 ro vga=838

where sda3 would be the swap partition.

3) logging in as root is the best idea i guess - at least thats what i did

4) most likely about the same as your root entry with a different uuid and mountpoint

edit... i'm slow wink

Last edited by konni (2009-03-01 21:53:33)

Offline

#4 2009-03-01 21:58:15

toad
Member
From: if only I knew
Registered: 2008-12-22
Posts: 1,775
Website

Re: How to change swap and home partition after installation

instead of cp -R I'd use cp -a


never trust a toad...
::Grateful ArchDonor::
::Grateful Wikipedia Donor::

Offline

#5 2009-03-01 22:21:32

blackhole
Member
From: Karlsruhe, Germany
Registered: 2008-12-14
Posts: 148
Website

Re: How to change swap and home partition after installation

Thanks to all of you guys. That's great!

One last question:
Would it also be possible to boot Linux without a swap partition? I mean, can I delete the old swap partition and create the new one via GParted and then boot into my system with the old swap partition still in my fstab? This will obviously result in an error, but can I still boot the system and then just modify the fstab entry to the new swap partition?

@Toad: What exactly is "cp -a" doing? In the man page it says something about archives. Where's the difference to "cp -R"?

//Edit: Oh, and what's the capital of beer? ;-)

Last edited by blackhole (2009-03-01 22:51:57)


Coming closer and closer to the ultimate goal: replacing boring old Windows XP desktop with shiny new Arch KDE 4 desktop. ^^
Already registered? Your vote counts!

Offline

#6 2009-03-01 22:33:25

toad
Member
From: if only I knew
Registered: 2008-12-22
Posts: 1,775
Website

Re: How to change swap and home partition after installation

Taken from the man page:

-a, --archive
              same as -dpR
...
       -d     same as --no-dereference --preserve=links
...
       -p     same as --preserve=mode,ownership,timestamps
...
       -R, -r, --recursive
              copy directories recursively

Also make sure you run the command twice, both as cp -a * and as cp -a .* (or at least I don't know how to put it into one command).

capital of beer = Munich big_smile I wish I were in Burton-on-Trent but the stuff they brew here is also drinkable tongue


never trust a toad...
::Grateful ArchDonor::
::Grateful Wikipedia Donor::

Offline

#7 2009-03-01 22:55:19

blackhole
Member
From: Karlsruhe, Germany
Registered: 2008-12-14
Posts: 148
Website

Re: How to change swap and home partition after installation

toad wrote:

Taken from the man page:

Erm, yeah. I am too stupid to read one line further down. I just saw "--archive" and my google reflex kicked in. Then I was confused...
Maybe I should grab a beer. What did you say again? Burton-upon-Trent? Let's see... ^^

Any thoughts on my Boot-your-Linux-without-a-swap-partition-and-turn-your-machine-into-a-useless-brick-project while I'm getting my beer?

Last edited by blackhole (2009-03-01 22:56:43)


Coming closer and closer to the ultimate goal: replacing boring old Windows XP desktop with shiny new Arch KDE 4 desktop. ^^
Already registered? Your vote counts!

Offline

#8 2009-03-01 23:20:31

ataraxia
Member
From: Pittsburgh
Registered: 2007-05-06
Posts: 1,553

Re: How to change swap and home partition after installation

Linux will run just fine without swap unless you have very little memory. You can even put your swap in a file instead of a partition with no loss of performance. (You can't do suspend-to-disk hibernation with to a swap file, though.)

Offline

#9 2009-03-02 07:38:27

toad
Member
From: if only I knew
Registered: 2008-12-22
Posts: 1,775
Website

Re: How to change swap and home partition after installation

Thanks for that, ataraxia. Swap to a file, that is standard procedure for another OS, isn't it - didn't know it would also work in Linux.

@ blackhole

I've heard (but have no personal experience) that you can run without a swap with 1GB of RAM, i.e. if your box is less than 4 years old chances are it should just work. Best way is to just comment the swap from the fstab, reboot and keep a live CD handy just in case smile

EDIT: Munich, mate, München. Dreadful Oktoberfest and all that.

Last edited by toad (2009-03-02 07:43:37)


never trust a toad...
::Grateful ArchDonor::
::Grateful Wikipedia Donor::

Offline

#10 2009-03-02 08:41:08

blackhole
Member
From: Karlsruhe, Germany
Registered: 2008-12-14
Posts: 148
Website

Re: How to change swap and home partition after installation

toad wrote:

Munich, mate, München. Dreadful Oktoberfest and all that.

Yeah, but you clearly favoured Burton-upon-Trent over München, mate. ;-)

Never been to the Oktoberfest. As a Swabian I'm faithful to the Wasen. ^^


Coming closer and closer to the ultimate goal: replacing boring old Windows XP desktop with shiny new Arch KDE 4 desktop. ^^
Already registered? Your vote counts!

Offline

#11 2009-03-02 09:19:47

toad
Member
From: if only I knew
Registered: 2008-12-22
Posts: 1,775
Website

Re: How to change swap and home partition after installation

Getting wildly off topic here smile

And yes, I do prefer a decent English pint over this fizzy Lager stuff. But hey, a man's got to do what a man's got to do, I'm not complaining...

Wasen? There is obviously a large cultural gap in my life I hadn't known about!


never trust a toad...
::Grateful ArchDonor::
::Grateful Wikipedia Donor::

Offline

#12 2009-03-02 15:43:33

blackhole
Member
From: Karlsruhe, Germany
Registered: 2008-12-14
Posts: 148
Website

Re: How to change swap and home partition after installation

toad wrote:

Getting wildly off topic here smile

And yes, I do prefer a decent English pint over this fizzy Lager stuff. But hey, a man's got to do what a man's got to do, I'm not complaining...

Wasen? There is obviously a large cultural gap in my life I hadn't known about!

To conclude this off topic talk: http://en.wikipedia.org/wiki/Wasen
Second largest beer festival after the Oktoberfest.

I assume you're not German, or at least not from the South. Otherwise you would know about the Wasen. ;-)


Coming closer and closer to the ultimate goal: replacing boring old Windows XP desktop with shiny new Arch KDE 4 desktop. ^^
Already registered? Your vote counts!

Offline

#13 2009-03-02 22:55:38

ataraxia
Member
From: Pittsburgh
Registered: 2007-05-06
Posts: 1,553

Re: How to change swap and home partition after installation

toad wrote:

Thanks for that, ataraxia. Swap to a file, that is standard procedure for another OS, isn't it - didn't know it would also work in Linux.

Standard procedure in both Windows and Mac OS X, actually.

Offline

#14 2009-03-05 01:02:12

blackhole
Member
From: Karlsruhe, Germany
Registered: 2008-12-14
Posts: 148
Website

Re: How to change swap and home partition after installation

PANIC!!!!!!

OK, I've done the first step. I deleted the Dell utility partition (/dev/sda1), moved all the partitions to the left and resized my swap partition (/dev/sda6). That's all I did via SystemRescueCD's GParted.

Then I rebooted, changed the swap partition's UUI in /etc/fstab, added the kernel parameter in menu.lst and Suspend to Disk was working beautifully. Next step would be to replace my NTFS partition (dev/sda5) by some ext3-partitions.

But first I have to sort out a major problem with your help!
When I tried to boot my Windows partition I got the following error message:

Windows could not start because the following file is missing:
<windows root>\system32\hal.dll

Please reinstall a copy of the above file.

So obviously this must be related to removing the Dell Utility partition. Funnily enough I don't have a /dev/sda1 anymore, although I thought the partitons might be relabeled. I dunno. What shall I do next to get my Windows running again?

Here's my "fdisk -l":

Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x41ab2316

   Device Boot      Start         End      Blocks   Id  System
/dev/sda2   *           1        3824    30716248+   7  HPFS/NTFS
/dev/sda3            3825        7397    28700122+   f  W95 Ext'd (LBA)
/dev/sda4            7398        9729    18731790   83  Linux
/dev/sda5            3825        7012    25607578+   7  HPFS/NTFS
/dev/sda6            7013        7397     3092481   82  Linux swap / Solaris

Here's my menu.lst:

# Config file for GRUB - The GNU GRand Unified Bootloader
# /boot/grub/menu.lst

# DEVICE NAME CONVERSIONS 
#
#  Linux           Grub
# -------------------------
#  /dev/fd0        (fd0)
#  /dev/hda        (hd0)
#  /dev/hdb2       (hd1,1)
#  /dev/hda3       (hd0,2)
#

#  FRAMEBUFFER RESOLUTION SETTINGS
#     +-------------------------------------------------+
#          | 640x480    800x600    1024x768   1280x1024
#      ----+--------------------------------------------
#      256 | 0x301=769  0x303=771  0x305=773   0x307=775
#      32K | 0x310=784  0x313=787  0x316=790   0x319=793
#      64K | 0x311=785  0x314=788  0x317=791   0x31A=794
#      16M | 0x312=786  0x315=789  0x318=792   0x31B=795
#     +-------------------------------------------------+

# general configuration:
timeout   8
default   0
color light-blue/black light-cyan/blue

# boot sections follow
# each is implicitly numbered from 0 in the order of appearance below
#
# TIP: If you want a 1024x768 framebuffer, add "vga=773" to your kernel line.
#
#-*

# Windows XP
title    Windows XP
root    (hd0,1)
makeactive
chainloader +1

# (0) Arch Linux
title  Arch Linux
root   (hd0,3)
kernel /boot/vmlinuz26 root=/dev/disk/by-uuid/4aef5a26-fdbe-4a48-a058-221a119f57b2 resume=/dev/sda6 ro vga=773
initrd /boot/kernel26.img

# (1) Arch Linux
title  Arch Linux Fallback
root   (hd0,3)
kernel /boot/vmlinuz26 root=/dev/disk/by-uuid/4aef5a26-fdbe-4a48-a058-221a119f57b2 ro
initrd /boot/kernel26-fallback.img

Hoping for your help... hmm

//edit:

Well I guess I've found the problem. The Windows BOOT.INI contains the wrong partition number, as I removed the partition BEFORE the windows partition.
I found some guides here:
http://ubuntuforums.org/showthread.php? … ng+hal.dll
http://ubuntuforums.org/showthread.php? … ng+hal.dll
http://www.kellys-korner-xp.com/xp_haldll_missing.htm

However as I need a tool for writing to my NTFS partition I was wondering whether I should use "ntfs-3g" although the guides above use "ntfsprogs". Which of the two packages would you recommend, if I want to mess up my NTFS-partition properly? ;-)

Last edited by blackhole (2009-03-05 01:28:36)


Coming closer and closer to the ultimate goal: replacing boring old Windows XP desktop with shiny new Arch KDE 4 desktop. ^^
Already registered? Your vote counts!

Offline

#15 2009-03-05 12:15:57

blackhole
Member
From: Karlsruhe, Germany
Registered: 2008-12-14
Posts: 148
Website

Re: How to change swap and home partition after installation

OK, I tried it using ntfsprogs now following those guides, but I got a bad surprise when I wanted to write back my boot.ini on my ntfs-partition:

schorsch@archie:~$ sudo ntfscp /dev/sda2 /home/schorsch/boot.ini boot.ini
Volume is scheduled for check.
Please boot into Windows TWICE, or use the 'force' option.
NOTE: If you had not scheduled check and last time accessed this volume
using ntfsmount and shutdown system properly, then init scripts in your
distribution are broken. Please report to your distribution developers
(NOT to us!) that init scripts kill ntfsmount or mount.ntfs-fuse during
shutdown instead of proper umount.
ERROR: couldn't mount volume: No such file or directory.

Any suggestions? I hope my windows-partition is not dead.

// Edit: I couldn't wait. ^^ I forced it and did a "sudo ntfscp -f /dev/sda2 /home/schorsch/boot.ini boot.ini"
That worked! Windows is booting again and I've learned something about the Windows boot process. Isn't Linux fun?! *grin*

Last edited by blackhole (2009-03-05 13:13:22)


Coming closer and closer to the ultimate goal: replacing boring old Windows XP desktop with shiny new Arch KDE 4 desktop. ^^
Already registered? Your vote counts!

Offline

Board footer

Powered by FluxBB