4

I duplicated a hard disk to a new larger one using the method suggested in Full DD copy from hdd to hdd.

After doing that df -h reports the original and smaller partition sizes from the original disk and gparted highlights the disparity and offers to fix them, though it seems unwise as they are mounted. If you look closely at the image you can see that Used + Unused < Size for the partitions with the yellow warning signs.

What command line tools can be used to fix the issue, and will it be safe for gparted to do it on mounted partition live? Ideally I should have done that before switching over to the target disk and rebooting from it. Gparted Snapshot

Below is the information dialog from gparted about the discrepancy and I edited the title to describe it better.

Gparted information dialog

  • extendfs /dev/sda6 ? You might need to specify an ext4 filesystem. – Archemar Jun 11 '16 at 8:44
3
  • If gparted only has to extend the partition or filesystem into unused space (immediately following the partition), then it should be safe to let it extend the partition and/or fs.

  • If, however, it has to MOVE any partitions around to make space for resizing, you'll have to boot with a gparted Live CD

  • See the man page for resize2fs (which is the command-line tool gparted will use to grow an ext2, ext3, and ext4 filesystem) for more details about resizing those filesystems.

    For ext2/3/4, growing a filesystem is generally not a problem and can safely be done while the fs is mounted.

    Shrinking a filesystem, however, is more troublesome and should be done while the fs is unmounted. If it's the rootfs, that means booting to a rescue CD/USB/PXE etc.


BTW, both dd and cat are amongst the worst ways to copy a linux system to another hard disk. Use Clonezilla, that's what it's for.

  • I have edited the question to indicate that it is about extending the file system to use the unallocated space within the partition. Is it safe for gparted to do it while the partitions are mounted? Both / and /home are in use. PS. I used the pv command suggested by Clive – vfclists Jun 11 '16 at 5:36
  • I already answered that in my first sentence - yes, it should be safe (I hesitate to say "definitely will be safe" only because there may be some weird and rare situations where it isn't entirely safe. Unless the fs or partition table is already corrupted, it's extremely unlikely to be a problem). BTW, see man resize2fs (which is the command-line tool gparted will use to grow an ext2/3/4 filesystem) for more details. – cas Jun 11 '16 at 5:47
  • Also BTW, pv is no better than using dd or cat alone. making exact bit-for-bit copies of a partition or dissk is the problem...copying the files in the partition is the best method (e.g. using cp or rsync or tar or cpio amongst many other tools). Clonezilla can and will use these and other tools to perform backup, restore, and cloning of disks and/or partitions. It's the best tool for the job. – cas Jun 11 '16 at 5:49
  • As you suggested resize2fs before Clive's answer, if you add it to the answer I can select yours as the correct one. – vfclists Jun 14 '16 at 7:36
2
sudo resize2fs /dev/sda6 

will solve your problem.

  • We prefer answers with a bit of explanation.  Also, your answer is essentially the same as the one given a year ago, except yours explicitly includes sudo (which is implicit) and gets the disk name right. – Scott Aug 1 '17 at 4:44
  • This happened to be the most precise answer for my situation. – yclian Apr 5 '18 at 2:40
1

If I understand correctly, your partitions are already filling up the new disk, but your filesystems aren't filling up the partitions. Since they're ext3 or ext4 filesystems, you can simply run resize2fs /dev/sda1 etc. as root, even while the filesystem is mounted, to grow it to the partition size.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.