I have Windows 7 and Debian dual-booted on my laptop. I'm getting cramped for space on the Debian side, so I want to remove the Windows partition and use the whole computer for Debian. I'm currently using a single partition for Debian (plus a swap partition), but would like to split /home into its own partition in the new arrangement.
Since the Windows partition is larger than all the Debian partitions, there's space enough for the whole linux installation in the current windows partition. So I'm thinking what I'd do is:
- reformat the 60GB windows 7 partition /sda2 to an extended partition with two two ext4 partitions, one 15 GB for /, the other 45 GB for /home
- move/clone my current / and /home directories to the new partitions
- reformat the partitions where the debian install was, freeing up 50GB of space
- resizing the new extended partition, and the /home partition in it, to incorporate the 50GB freed in step 3
- leave a 2 GB at the end for swap
I've posted my fdisk -l
below.
My questions:
- Is this a sensible approach?
- How do I do step 2? Can I move the / directory without having to reinstall it?
- I'm assuming that 4 will be straightforward, since I'll be resizing by moving the end of the partition, not the beginning – is that correct?
fdisk -l Disk /dev/sda: 120.0 GB, 120034123776 bytes 255 heads, 63 sectors/track, 14593 cylinders, total 234441648 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x45689f01 Device Boot Start End Blocks Id System /dev/sda1 * 2048 616447 307200 7 HPFS/NTFS/exFAT /dev/sda2 616448 127768575 63576064 7 HPFS/NTFS/exFAT /dev/sda3 127770622 234440703 53335041 5 Extended /dev/sda5 127770624 230021119 51125248 83 Linux /dev/sda6 230023168 234440703 2208768 82 Linux swap / Solaris
Best Answer
I'd suggest using LVM. To switch over, something like this:
/
and/home
(any reason you're splitting them? You don't need to.) (lvcreate)( cd /old-root && tar --one-file-system -c . ) | ( cd /new-root && tar vx )
update-initramfs -u
/new-root/{proc,sys,boot}
), and reboot./proc/mounts
. Confirm your data is present. (You do have backups too, right?) VERY IMPORTANT./
and/home
logical volumes using lvextend followed by resize2fs (or whichever tool for your filesystem). This can be done online, with your system running.Once you're on LVM, any future disk changes are much easier. You can use the LVM commands to do pretty much any disk change, with the system running even.
(Note: I haven't done this for a bit, I may have missed a step or two, but I'm pretty sure I haven't missed anything catastrophic. And of course, your original install & data is still around until after you've confirmed you're booted onto the new rootfs)