How to use VideoLAN in live mode?

Maj 19th, 2012 Brak komentarzy

After I started my journey with squashfs I encountered problem with VideoLAN as I couldn’t start it.

Problem

Error message:

$ vlc
VLC media player 2.0.1 Twoflower (revision 2.0.1-0-gf432547)
[0x23b9108] main libvlc error: No plugins found! Check your VLC installation.

More verbose output:

$ vlc -v
VLC media player 2.0.1 Twoflower (revision 2.0.1-0-gf432547)
[0x1b8c108] main libvlc warning: cannot read /livefs.squashfs/usr/lib/vlc/plugins/plugins.dat (No such file or directory)
[0x1b8c108] main libvlc error: No plugins found! Check your VLC installation.

As seen above it just searched for plugins in non-existent place.

Solution 1

Create a symbolic link so VideoLAN would see plugins:

$ sudo ln -s / /livefs.squashfs

Solution 2

Use environmental variable so VideoLAN would use correct path:

$ export VLC_PLUGIN_PATH=/usr/lib/vlc/plugins/

Footnotes

I found these solutions while reading Linux Mint Forums and the videolan forums.

Tagi:, ,

How to download YouTube videos using console application?

Maj 17th, 2012 Brak komentarzy

The easiest way to download YouTube videos is to use youtube-dl.

To install it using Debian based distribution like Ubuntu use command:

$ sudo apt-get install youtube-dl

Example usage:

$ youtube-dl http://www.youtube.com/watch?v=O5D1O7eb_H4
[youtube] Setting language
[youtube] O5D1O7eb_H4: Downloading video webpage
[youtube] O5D1O7eb_H4: Downloading video info webpage
[youtube] O5D1O7eb_H4: Extracting video information
[download] Destination: O5D1O7eb_H4.flv
[download] 100.0% of 124.37M at   87.78k/s ETA 00:00
Tagi:,

How to backup DOS-type partition table/GPT and LVM metadata?

Maj 14th, 2012 Brak komentarzy

DOS partion table

We can use sfdisk to dump partition table in usable format and store it:

$ sudo sfdisk -d /dev/sda > sda_partitions

Partition table can be restored using stored backup:

$ sudo sfdisk /dev/sda < sda_partitions

Partition table can be easily cloned (from sda to sdz in this example):

$ sudo sfdisk -d /dev/sda | sfdisk /dev/sdz



GPT

To backup GUID partition table use sgdisk command (from gdisk package):

$ sudo sgdisk -b sda_gpt_backup /dev/sda

Restore it in similar way:

$ sudo sgdisk -l sda_gpt_backup /dev/sda



LVM

To backup LVM metadata for volume group vol_test to vol_test_backup file use command:

$ sudo lvm vgcfgbackup -f vol_test_backup vol_test

To restore volume group metadata use similar command:

$ sudo lvm vgcfgbackup -f vol_test_backup vol_test

To restore physical volume metadata (with specified UUID to /dev/sda1 device):

$ sudo pvcreate --restorefile vol_test_backup --uuid rRD... /dev/sda1

There is a little more work to be done in this case (beyond this short post) so jump directly to Red Hat – Logical Volume Manager Administration.

Tagi:,

How to check stored WiFi passwords on Android 2.1?

Maj 11th, 2012 Brak komentarzy

On rooted phone go to /data/misc/wifi/ directory and open wpa_supplicant.conf file.

In case of any questions look at the screen shots below.

Tagi:

How to get disk UUID?

Maj 10th, 2012 Brak komentarzy

Recently I needed to know UUID (universally unique identifier) of my bootable USB root partition as it is better way to distinguish storage devices because (external) device names can change depending on connection order.

There are at least couple of ways to get UUIDs and not all of them require root access:

$ ls -l /dev/disk/by-uuid/* 
lrwxrwxrwx 1 root root 10 maj  9 18:05 /dev/disk/by-uuid/5d2f85fe-b555-4504-a87f-3d1c6513c7d4 -> ../../sda2
lrwxrwxrwx 1 root root 10 maj  9 18:05 /dev/disk/by-uuid/678e905f-68cc-449e-99a9-cb90d7011d23 -> ../../sdb1
lrwxrwxrwx 1 root root 10 maj  9 18:05 /dev/disk/by-uuid/687aa5e4-3863-4529-a8bf-fa526716f523 -> ../../sdb2
lrwxrwxrwx 1 root root 10 maj  9 18:05 /dev/disk/by-uuid/8252dada-3e65-401b-b0cf-0123a7b62df6 -> ../../sda1
lrwxrwxrwx 1 root root 10 maj  9 18:05 /dev/disk/by-uuid/8b19014d-442a-4e2e-8367-569f000afaa0 -> ../../sda3
$ ls /dev/disk/by-uuid/* | xargs file
/dev/disk/by-uuid/5d2f85fe-b555-4504-a87f-3d1c6513c7d4: symbolic link to `../../sda2'
/dev/disk/by-uuid/678e905f-68cc-449e-99a9-cb90d7011d23: symbolic link to `../../sdb1'
/dev/disk/by-uuid/687aa5e4-3863-4529-a8bf-fa526716f523: symbolic link to `../../sdb2'
/dev/disk/by-uuid/8252dada-3e65-401b-b0cf-0123a7b62df6: symbolic link to `../../sda1'
/dev/disk/by-uuid/8b19014d-442a-4e2e-8367-569f000afaa0: symbolic link to `../../sda3'
$ find /dev/disk/by-uuid/* -exec echo -n {} "-> " \; -exec readlink {} \; | sort -k2 | sed 's/\.\.\///g'
/dev/disk/by-uuid/8252dada-3e65-401b-b0cf-0123a7b62df6 -> sda1
/dev/disk/by-uuid/5d2f85fe-b555-4504-a87f-3d1c6513c7d4 -> sda2
/dev/disk/by-uuid/8b19014d-442a-4e2e-8367-569f000afaa0 -> sda3
/dev/disk/by-uuid/678e905f-68cc-449e-99a9-cb90d7011d23 -> sdb1
/dev/disk/by-uuid/687aa5e4-3863-4529-a8bf-fa526716f523 -> sdb2
$ sudo blkid
/dev/loop0: TYPE="squashfs" 
/dev/sda1: UUID="8252dada-3e65-401b-b0cf-0123a7b62df6" TYPE="ext4" 
/dev/sda2: UUID="5d2f85fe-b555-4504-a87f-3d1c6513c7d4" TYPE="swap" 
/dev/sda3: UUID="8b19014d-442a-4e2e-8367-569f000afaa0" TYPE="ext4" 
/dev/sdb1: UUID="678e905f-68cc-449e-99a9-cb90d7011d23" TYPE="ext4" 
/dev/sdb2: LABEL="home-rw" UUID="687aa5e4-3863-4529-a8bf-fa526716f523" TYPE="ext4"
$ sudo blkid -o list
device               fs_type   label       mount point       UUID
-------------------------------------------------------------------------------------------------
/dev/loop0           squashfs              (in use)                                                              
/dev/sda1            ext4                  (not mounted)     8252dada-3e65-401b-b0cf-0123a7b62df6
/dev/sda2            swap                  (not mounted)     5d2f85fe-b555-4504-a87f-3d1c6513c7d4
/dev/sda3            ext4                  /media/disk-1     8b19014d-442a-4e2e-8367-569f000afaa0
/dev/sdb1            ext4                  (not mounted)     678e905f-68cc-449e-99a9-cb90d7011d23
/dev/sdb2            ext4       home-rw    /home             687aa5e4-3863-4529-a8bf-fa526716f523
$ cat /dev/.blkid.tab                                                                                                 
<device DEVNO="0x0700" TIME="1336670951.551604" TYPE="squashfs">/dev/loop0</device>                                                                                                             
<device DEVNO="0x0801" TIME="1336671278.523695" UUID="8252dada-3e65-401b-b0cf-0123a7b62df6" TYPE="ext4">/dev/sda1</device>                                                                      
<device DEVNO="0x0802" TIME="1336670951.552155" UUID="5d2f85fe-b555-4504-a87f-3d1c6513c7d4" TYPE="swap">/dev/sda2</device>                                                                      
<device DEVNO="0x0803" TIME="1336670951.552241" UUID="8b19014d-442a-4e2e-8367-569f000afaa0" TYPE="ext4">/dev/sda3</device>                                                                      
<device DEVNO="0x0811" TIME="1336670951.568408" UUID="678e905f-68cc-449e-99a9-cb90d7011d23" TYPE="ext4">/dev/sdb1</device>
<device DEVNO="0x0812" TIME="1336670951.568610" LABEL="home-rw" UUID="687aa5e4-3863-4529-a8bf-fa526716f523" TYPE="ext4">/dev/sdb2</device>
$ cat /dev/.blkid.tab | sed 's/.*UUID="\(.*\)"\ .*>\(.*\)<.*/\1 -> \2/g' | grep -v ^\< | sort -k2
8252dada-3e65-401b-b0cf-0123a7b62df6 -> /dev/sda1
5d2f85fe-b555-4504-a87f-3d1c6513c7d4 -> /dev/sda2
8b19014d-442a-4e2e-8367-569f000afaa0 -> /dev/sda3
678e905f-68cc-449e-99a9-cb90d7011d23 -> /dev/sdb1
687aa5e4-3863-4529-a8bf-fa526716f523 -> /dev/sdb2
$ sudo tune2fs -l /dev/sda1 | grep UUID | tail -c 37
8252dada-3e65-401b-b0cf-0123a7b62df6

To change device UUID use tune2fs and uuidgen commands together:

$ sudo tune2fs -U `uuidgen` /dev/sda3
Tagi:,

How to mount software RAID1 member using mdadm

Maj 8th, 2012 Brak komentarzy

Just a moment ago I connected my old hard drive and realized that it was RAID member:

$ sudo fdisk -l /dev/sdd
Disk /dev/sdd: 250.1 GB, 250058268160 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488395055 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x90909090
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1   *        2048     2099199     1048576   fd  Linux raid autodetect
/dev/sdd2         2099200     6293503     2097152   82  Linux swap / Solaris
/dev/sdd3         6293504    69208063    31457280   fd  Linux raid autodetect
/dev/sdd4        69208064   488394751   209593344   fd  Linux raid autodetect

I couldn’t mount it out of the box:

$ sudo mkdir /mnt/old_hdd 
$ sudo mount /dev/sdd4 /mnt/old_hdd 
mount: unknown filesystem type 'linux_raid_member'

Fortunately I used RAID1 array:

$ sudo mdadm --examine /dev/sdd4
/dev/sdd4:
          Magic : a92b4efc
        Version : 1.2
    Feature Map : 0x0
     Array UUID : 957e7cb5:bfd41f70:9cb84b0d:f53e5a4c
           Name : milosz-desktop:2
  Creation Time : Sat Aug 20 18:48:26 2011
     Raid Level : raid1
   Raid Devices : 2
 
 Avail Dev Size : 419184640 (199.88 GiB 214.62 GB)
     Array Size : 419184496 (199.88 GiB 214.62 GB)
  Used Dev Size : 419184496 (199.88 GiB 214.62 GB)
    Data Offset : 2048 sectors
   Super Offset : 8 sectors
          State : clean
    Device UUID : db8a694f:750a0ded:22a6d046:5c4db280
 
    Update Time : Tue May  8 20:50:32 2012
       Checksum : 75dbc3b6 - correct
         Events : 191
 
 
   Device Role : Active device 1
   Array State : .A ('A' == active, '.' == missing)

I needed to create md virtual device using mdadm:

$ sudo mdadm -A -R /dev/md9 /dev/sdd4
mdadm: /dev/md9 has been started with 1 drive (out of 2).

So it could be mounted without hassle:

$ sudo mount /dev/md9 /mnt/old_hdd/
$ mount | grep ^/dev/md9
/dev/md9 on /mnt/old_hdd type ext4 (rw)

After data was moved I unmounted file system and removed md virtual device.

$ sudo umount /mnt/old_hdd 
$ sudo mdadm -S /dev/md9
mdadm: stopped /dev/md9
Tagi:,

Ubuntu – Boot to RAM – Couple of notes

Maj 2nd, 2012 Brak komentarzy

This post contains couple of notes on this topic in form of very short guide.

Requirements


First step – create virtual machine
Create new virtual machine using VirtualBox and install minimal Ubuntu OS.

Second step – install required packages
Install squashfs-tools package so you can create squashfs image later:

$ sudo apt-get install squashfs-tools

Install live-boot package with dependencies (live-boot-initramfs-tools) so you can use boot to ram:

$ sudo apt-get install live-boot


Third step – prepare image contents
Create new directory and copy root file system contents:

$ sudo mkdir /squashfs

You need to exclude contents of directory /live and one created just moment ago.
You can also exclude contents of directories like /boot/*, /tmp/*, …

$ sudo rsync -a --delete --one-file-system / /squashfs \
    --exclude=/live --exclude=/squashfs

It’s good idea to remove root file system from /squashfs/etc/fstab file now.

Fourth step – create squashfs image
Create /live directory (squashfs image will be stored here):

$ sudo mkdir /live

Create squashfs image:

$ sudo mksquashfs /squashfs /live/livefs.squashfs -noappend -always-use-fragments


Fifth step – configure grub2
Change GRUB_TIMEOUT to -1 in /etc/defaults/grub so it will be waiting forever in boot menu.

Update grub configuration:

$ sudo update-grub

Check your kernel release:

$ uname -r
3.0.0-17-generic

Edit /etc/grub.d/40_custom file to add new entry in grub2 menu and take into account your kernel release:

menuentry "Live minimal OS" {
 set root='(hd0,1)'
 linux /boot/vmlinuz-3.2.0-24-generic boot=live toram=livefs.squashfs
 initrd /boot/initrd.img-3.2.0-24-generic
}

Update grub configuration again:

$ sudo update-grub


Sixth step – check it out!
Reboot system and check it out:

$ sudo reboot


Couple of notes
Compression is very effective as it can compress 2 GB file system (KDE + Libre Office + couple of smaller applications) to around 700 MB.

System becomes blazingly fast and you can easily create live usb this way.

To make your changes persistent just create partitions labelled accordingly live-rw for root, home-rw for home file system and add persistent parameter to kernel boot parameters. If you can’t create new partitions then create files in root directory (not in live fs). For example to create persistent home (200MB, without reserved blocks) use commands:

$ sudo dd if=/dev/zero of=/home-rw bs=1M count=200
$ sudo mkfs.ext4 /home-rw
$ sudo tune2fs -m 0 /home-rw
$ sudo tune2fs -L home-rw /home-rw

Apparmor doesn’t work very well so you need to remove it.

To see how it works go to directory /usr/share/initramfs-tools/scripts and start with reading live file. After any modifications don’t forget to update initramfs:

$ sudo update-initramfs -u

Don’t forget to read live-boot manual page.

Couple of common errors

only one RO file system supported with exposedroot

Just remove livefs.squashfs file from /squashfs/live/ directory and create squashfs image again.

a wrong rootfs was mounted

This error means that live-boot package was not installed on system that was used to create squashfs image. Just install it and create image again.

Tagi:

Ubuntu – How to add custom grub entry?

Maj 1st, 2012 Brak komentarzy

Edit /etc/grub.d/40_custom file to add custom entry in grub2 menu (this is just an example):

menuentry "Live" {
 set root='(hd0,1)'
 linux /boot/vmlinuz-3.2.0-24-generic boot=live toram=fs.squashfs
 initrd /boot/initrd.img-3.2.0-24-generic
}

After applying changes update grub configuration:

# update-grub

To print kernel release use uname command:

$ uname -r
3.2.0-24-generic
Tagi:

Ubuntu – Where to download Minimal CD?

Maj 1st, 2012 Brak komentarzy

Recently I started to use Minimal CD for customized installation so I need to write down places where I can get it.

Minimal CD can be downloaded at help.ubuntu.com/community/Installation/MinimalCD.

Actually official site doesn’t contain version 12.04 yet but it can be directly downloaded for i386 and amd64 versions.

Tagi:

How to check the progress of dd

Kwiecień 29th, 2012 Brak komentarzy

To check the progress of dd execute command:

# kill -USR1 `pgrep -u \`whoami\` ^dd`

This command will send USR1 signal to every dd process owned by user.

When dd process receives USR1 signal it will print overall progress:

# dd if=/dev/sdb of=./sdb.raw
133345+0 records in
133344+0 records out
68272128 bytes (68 MB) copied, 3.00926 s, 22.7 MB/s
...
15244673+0 records in
15244673+0 records out
7805272576 bytes (7,8 GB) copied, 2511,34 s, 3,1 MB/s
...
Tagi: