1

I have a virtual machine on my Windows 10 desktop (VMWare WS) running Debian 9 which needed 12 GB to install, I gave it 15 GB for safe measure. So it's effectively a 15 GB hard disk.

I need to make several copies of this VM onto 8 GB bootable flash drives.

So I then stripped it down (removed lots of packages I didn't need) and used GParted Live to resize and reduce the partitions such that the system only uses about 6 GB total. Boots fine, no issues. Even moved the swap partition so that the last ~9 GB of space is totally unallocated.

So I now have a 6 GB system that I want to put onto an 8 GB flash drive...

I tried using GParted to copy the partitions and was met with a little blinking '_' when I tried to boot.

Google-fu and yeah GParted doesn't copy GRUB so no go.

I then tried Clonezilla device-device cloning, which complained about the target disk being too small because Clonezilla is too effn' stupid to see that the last 9 GB of space on the source disk isn't being used.

I used an override in the expert section (-icds) to ignore the disk size and copied over the VM to a flash drive. Booted the drive on one of my machines, and was met with GRUB (yay!).

Unfortunately that joy was short lived, as the system showed...

/dev/sdb1: clean, 119211/349504 files, 1052948/1408000 blocks _

And my friend the blinky cursor reappeared.

So what am I doing wrong here? How does one resize Linux to be smaller, and copy it onto one or more drives without having to completely rebuild/reinstall/recompile the damn OS?

Cody Smith
  • 247
  • 2
  • 10

2 Answers2

0

GParted does everything but installs the GRUB. However, everything needed for the GRUB including the settings is on the copied partitions.

  1. Work outside the system to be copied (e.g. livecd).

  2. Copy (shrinked) partitions with GParted.

  3. Install GRUB. Here, USB stick /dev/sdx is mounted to /mnt/stick:

    grub-install --force --removable --boot-directory=/mnt/stick/boot /dev/sdx
    
Esa Jokinen
  • 46,944
  • 3
  • 83
  • 129
0

I would do it like this:

  1. Make the partitions you want in the flash drive.
  2. Copy the contents of corresponding filesystems to the flash drive with cp -a -x command. This command copies only the contents of one filesystem, so you need to run it for all filesystems (/ and /boot in default Debian installation).
  3. Run dpkg-reconfigure grub-pc, which will ask you for options and where you want to install GRUB. Select the flash drive here.

After this you should have a bootable flash drive.

Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63