Moe's Techblog

USB stick gets mounted readonly

When plug in an USB stick it happens with Ubuntu that it gets mounted read-only. Even with rw mount option it is not possible to write. Often the mount point directoy is not writeable (or even accessible) to the user. This could be solved by setting the ACLs.

To see the actual access rights

$ ls -ld /media/<username>
drwxrwx---+ 2 <username> <username> 4096 Mar 4 18:32 /media/<username>

where the + charcter indicates the use of ACL. These ACL can be shown as followed

$ getfacl /media/<username>

# file: <username>/
# owner: <username>
# group: <username>
user::rwx
user:<username>:r-x
group::---
mask::r-x
other::---

In this example, the user is read only. This can be easily changed to read-write (rw)

setfacl -m u:<username>:rwx /media/<username>

Eventually you have to reset the dirty-bit of the FAT filesystem of your USB stick.

dosfsck /dev/sdc1

Defect initramfs during Ubuntu startup

Trying to start a computer with Ubuntu 16.04 LTS leads to the following error message

 Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

and the computer will not boot into the OS.

Due to update processes of the linux kernel the initramfs is defect.

By googleing you can find this error message and possible solutions quite often and I just want to summarize their and my experiences.

A good solution is to boot your computer with a Ubuntu Live from an USB stick or DVD. Just follow the instructions on the Ubuntu homepage how to create such an USB stick (or DVD). After booting in your rescue system, open a terminal and identify the harddisk your systems is installed.

sudo fdisk -l

Mount this harddisk (e.g. /dev/sda1) and the devices from your host rescue system to create a chroot environemnt.

sudo mount /dev/sdax /mnt
sudo mount --bind /dev /mnt/dev
sudo mount --bind /dev/pts /mnt/dev/pts
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys
sudo chroot /mnt 

To create a new initramfs you have to find out which kernel you want to boot. Just have a look into /boot and identify the latest one. Just type

update-initramfs -u -k 4.4.0-66-generic

with the version number you found.

When no error occurs you can finally reinstall grub by typing the following and reboot

update-grub2

In my case I got some erros due to the big number of older kernels in the /boot directory. After deleting them manually the grub update worked fine and I could manage to restart the computer.

Saving embedded video streams in firefox

Some time you see an embedded video stream in your firefox browser and you want to download it. There are several addons, but yozu can also manage without any additional software.

  1. Enlarge your firefox cache
  2. open the page with the video
  3. clear your browser cache
  4. open a new browser tab and enter
    about:cache?device=disk
  5. go back to the tab with video and reload the page
  6. refresh the tab with the cache overview and locate the largest file (which should be your video)
  7. copy the shown location to an other browser tab.
  8. by right clicking , you can save the video

Editing files with gftp2 and gvim as external editor

With the ftp client gftp2 you can open files in an external editor. Unfortunately all changes on the files are lost with the default properties of gftp2.

Following error message is shown

/tmp/gftp-view.ojAg2S.php erfolgreich mit 23,36 KB/s übertragen
/tmp/gftp-view.ojAg2S.php erfolgreich gelöscht

The editor app is started but the focus goes instantly back to gftp2. So, gftp2 does not recognize file changes in the editor (e.g. gvim). You have to download the file to your local directory, edit and upload it back to your server.

Calling gvim with -f option, gvim stays in focus and files can be edited directly on the remote computer. This can be easily achieved in the gftp2 configuration. In the gftprc (/etc/gftp/gftprc or ~/.gftp/gftprc) config file you have to add this option

# Das Standardprogramm zur Dateibearbeitung.
edit_program=gvim -f
Home