Clone with mkusb
You can clone from a drive to another drive with mkusb
. Start via the graphical interface or with
dus /dev/sdx
where x is the device letter or the source in the cloning operation. The target will be selected in a safe way via menus.
- mkusb wraps a safety belt around
dd
- if there is a GUID partition table, GPT, mkusb fixes the backup partition table at the tail end of the drive. (Otherwise you must do that manually for example with
gdisk
.)
After the cloning you can edit the partitions with gparted
. If you touch only the casper-rw
partition and the usbdata
partition (amd if an MSDOS partition table the extended partition), booting will not be affected.
Edit: How to edit the partitions to fill the drive.
- Be sure you have a backup (for example the original drive).
- Read how to use
gparted
.
- Boot from another drive
- Unmount all partitions on the target drive
- Start
gparted
and check that there are no lock symbols on /dev/sdb1
and /dev/sdb5
.
- Move
/dev/sdb1
to the tail end (to the right)
- Drag its left border of
/dev/sdb1
to the left until the size is what you want
- Drag the right border of /dev/sdb5` to the right to use all remaining unallocated drive space. The two partitions should 'touch each other'.
- Check that things are as you want them.
- Click on the tick icon to start the actions.
- Please wait ... it will take a long time. Be sure there is enough power (do not run on battery).
If you cloned with dd
you need to repair the backup partition table at the tail end of the drive with gdisk
or maybe use gpt-fix.
Edit: gdisk
command options cut from gpt-fix
echo \
"v
x
e
r
d
w
y" \
| gdisk "$1"
where "$1"
should be replaced by the target device /dev/sdx
, if run directly (not within the shellscript).
These command letters are explained in
man gdisk
The crucial commands are
in the expert's menu
e Move backup GPT data structures to the end of the disk. Use this
command if you've added disks to a RAID array, thus creating a
virtual disk with space that follows the backup GPT data struc‐
tures. This command moves the backup GPT data structures to the
end of the disk, where they belong.
and in the the recovery & transformation menu
d Use main GPT header and rebuild the backup. This option is
likely to be useful if the backup GPT header has been damaged or
destroyed.
The other commands are verifying, moving between menus and writing.
Links added by the OP, @BlueSkies:
Unable to unmount a partition with GParted - is this a problem?
GParted cannot finish step 1
GParted showing now
After cloning with mkusb, copying partitions from the original USB stick and booting from the new-larger stick, I'm unable to access the usbdata.
![Access to usbdata partition blocked](https://i.stack.imgur.com/UCdYs.png)
Please advice. Thanks!
Advice: Please post the output of the following command lines (when booted from the new-larger stick),
sudo lsblk -f
sudo lsblk -m
sudo ls -l /mountpoint-to-usbdata
sudo ls -l /mountpoint-to-casper-rw
where you enter the actual mountpoints to see usbdata
and casper-rw
.
This will help me understand what is the problem, so that I can suggest what to do next.
Please edit your original question to enter these output texts instead of here in my answer. Indent each line 4 characters in order to render the output as code. You can mark (high-light) the text and click on the {}
icon at the head of the editing window to make those indentations quickly.
Outputs of the four above-mentioned commands:
The command
sudo lsblk -f
gives the following results
![enter image description here](https://i.stack.imgur.com/T2n5a.png)
The other one (sudo lsblk -m
) outputs the following info:
![sudo lsblk -m results](https://i.stack.imgur.com/NDqGr.png)
The last two commands and results:
![result1](https://i.stack.imgur.com/WwE4a.png)
![enter image description here](https://i.stack.imgur.com/NbSJm.png)
Best Answer
How to erase / delete / blank or wipe a disk
I’m sure there are other methods, but the one I prefer to use is the one that uses
dd
to copy zeros, or random data in the file system I want to wipe.So, run this command if you want to erase your… let’s say microSD card.
Suppose it is mounted on
/dev/sdd1
:If you do not want to wait too much, you can fill the partition with zeros instead of random data:
Both are secure, but IMHO the first one may be better, but of course I can be wrong.
Once again, be sure to double check, or better triple check on which partition you are going to apply this, you will not be warned by Linux, and the result can not be undone.
A good practice could be to first make an image of the disk and then wipe it. If you want to proceed that way, do this.
Then wipe it
You can then recover the data by doing
Info taken from this site.