Copying to usb is quite troublesome in linux, whereby the "cp" command or file manager reports that the file has been copied successfully, but if your usb drive has LED, you can see that the LED is flashing frantically as if it is doing some hard work in the background.
Showing posts with label usb. Show all posts
Showing posts with label usb. Show all posts
Monday, February 10, 2020
Expediting Files Copy to USB
This is due to the default ubuntu linux setting for kernel parameter called vm.dirty_bytes is being set 0 (unlimited), which means that after copying process has been started, the file will be copied to buffer as a whole, the process that started the copying (file manager or "cp" command) will be notified that copy has completed, but in the background, the file is actually sitting in the buffer, waiting to be written to the usb driver.
This will results in the file manager showing 100% copied, but the file is not actually being written to the usb.
One of the way to expedite the copy process is, by limiting the size of the buffer, so the file will get written to the usb faster.
You can check what is the current buffer (vm.dirty_bytes) value by running:
$ sudo sysctl vm.dirty_bytes
vm_dirty_bytes = 0
Change the current value to something small (like 15MB)
$ sudo sysctl vm.dirty_bytes=15000000
Start the copying process
$ cp some-big-file /mnt
The copy process will complete faster.
To make the change permanent:
$ echo "vm.dirty_bytes=15000000" | sudo tee -a /etc/sysctl.conf
Reboot your machine
$ sudo reboot
Once rebooted, check whether the value stays
$ sudo sysctl vm.dirty_bytes
vm_dirty_bytes = 15000000
Done.
Credit to:
Labels:
kernel,
linux mint,
Ubuntu,
usb
Tuesday, November 6, 2018
How to test that your usb live cd is working
To do this, you need qemu-kvm. Install it:
$ sudo apt install qemu-kvm
Check the address of your usb, by using dmesg
$ dmesg | grep sd
Once you have the address, you can start it using below command (make sure you allocate at least 1024M memory, else it will return kernel panic)
$ sudo qemu-system-x86_64 -m 1024 -hda /dev/sdb
To use a cdrom, you can use below command
$ sudo qemu-system-x86_64 -m 1024 -cdrom /dev/cdrom
You can also test an iso file, using below command
$ sudo qemu-system-x86_64 -m 1024 -cdrom centos.iso
Subscribe to:
Posts (Atom)