Reading and Writing Input/Output devices

My linux machine can clearly read/write to USB in gui mode. I’m a little perplexed that I can’t get it to work in command mode. Obviously launching the gui requires init 5 privileges – maybe that has something to do with it. /etc/fstab looks like this (reparsed for display).
/dev/hda4 / reiserfs acl,user_xattr 1 1
/dev/hda2 /boot ext3 acl,user_xattr 1 2
/dev/hda3 /var reiserfs acl,user_xattr 1 2
/dev/hda1 /swap swap pri=42 0 0
devpts /dev/pts devpts mode=0620,gid=5 0 0
proc /proc proc defaults 0 0
usbfs /proc/bus/usb usbfs noauto 0 0
sysfs /sys sysfs noauto 0 0
/dev/cdrecorder /media/cdrecorder subfs noauto,fs=cdfss,rw,procuid,nosuid,nodev,exec,iocharset=utf8 0 0

/etc/mtab looks like this:

/dev/hda4 / reiserfs rw,acl,user_xattr 0 0
proc /proc proc rw 0 0
sysfs /sys sysfs rw 0 0
tmpfs /dev/shm tmpfs rw 0 0
devpts /dev/pts devpts rw,mode=0620,gid=5 0 0
/dev/hda2 /boot ext3 rw,acl,user_xattr 0 0
/dev/hda3 /var reiserfs rw,acl,user_xattr 0 0
usbfs /proc/bus/usb usbfs rw 0 0
/dev/sda1 /media/PUBLIC subfs rw,nosuid,nodev,sync,fs=floppyfss,procuid 0 0

then i mount /media/cdrecorder and mtab looks like this:
/dev/hda4 / reiserfs rw,acl,user_xattr 0 0
proc /proc proc rw 0 0
sysfs /sys sysfs rw 0 0
tmpfs /dev/shm tmpfs rw 0 0
devpts /dev/pts devpts rw,mode=0620,gid=5 0 0
/dev/hda2 /boot ext3 rw,acl,user_xattr 0 0
/dev/hda3 /var reiserfs rw,acl,user_xattr 0 0
usbfs /proc/bus/usb usbfs rw 0 0
/dev/sda1 /media/PUBLIC subfs rw,nosuid,nodev,sync,fs=floppyfss,procuid 0 0
/dev/hdc /media/cdrecorder subfs rw,nosuid,nodev,fs=cdfss,procuid,iocharset=utf8 0 0

protections for usb are rw – i know i reset them from ro to rw for /media/cdrecorder using vi. perhaps i also did this for /proc/bus/usb in mtab (looking at the /root/.bash_history file, I am pretty sure I didn’t).

now when i run ls -tal /proc/bus/usb it looks like this.
total 0
-r–r–r– 1 root root 0 Jul 22 00:44 devices
dr-xr-xr-x 6 root root 0 Jul 22 00:44 ..
dr-xr-xr-x 2 root root 0 Jul 22 00:43 001
drwxr-xr-x 3 root root 0 Jul 22 00:43 .

root seemingly has write privileges, and i am logged in as root. so, i changed the write privileges to add g first and then o next, to see if that changed my ability to write, but it didn’t. ls -tal shows that the priveleges did indeed change,
total 0
-r–r–r– 1 root root 0 Jul 22 00:44 devices
dr-xr-xr-x 6 root root 0 Jul 22 00:44 ..
dr-xr-xr-x 2 root root 0 Jul 22 00:43 001
drwxrwxrwx 3 root root 0 Jul 22 00:43 .

but I am apparently not being recognized as being in any of those categories: root, group, owner :-(. Actually, I think the problem must lie with read/write priveleges in the stage of the boot that I am in, because whoami does indeed return root as an answer. I am sure that it can be done, because the gui interface smoothly does it when I move up to init 5.

I decided to try to make a backup of the entire boot sector onto CD using the program K3b from the CD/DVD burning option in Multimedia (K menu). It was my first CD write and I wanted to make sure this worked. Using Memorex 52X 700MB CD-R CDs, I first created a tar file using tar -c -j /boot > boot.tar, then created a subdir dir_iso and put the file there. Using mkisofs -o badboot.iso dir_iso, I made the iso, and then successfully wrote it to CD through the gui K3b program. The trumpets sounded on the computer!!!!

It’s interesting that this worked despite the fact that I had redefined the /dev/hdc entry in /etc/fstab to /dev/cdrecorder using vi.

What else is interesting is that this apparently worked once, and could never be reproduced by me. So, trying to use the cdrecord command on commandline. That also used to work, but now doesn’t. cdrecord -scanbus gave me a list of active scsi devices on the system once (the only one that came up was the USB flash drive), but it now just hangs, and says that this version is an unofficial (modified) version.
On the downside, remote? keystroke logging has been implemented on the Windows 7 system that I’m using to post with. The whole system is unbearably slow. In the bottom righthand corner of the windows box, it says, Windows 7 Build 7600 This copy of Windows is not genuine. I suppose someone thinks I’m manic…

#51 Pit Bull Terrier/Labrador Retriever Mix – Large – Adult – Female
Approx. 4yrs old..approx. 60lbs…Very sweet dog, friendly, goofy, great on leash, good with dogs she met, eager to please, very smart, not hyper, affectionate.. This dog will be euthanized 7/28/11 if no one rescues/adopts.

If your interested in adopting this dog please contact Sherry the ACO Immediately. Viewing is by Appointment Only:
860-757-4395 or 860-305-6764 (call both numbers and leave a message if there is no answer). Also email her @

Please do not say you can rescue a dog if you can’t. These dogs have urgent deadlines to be adopted or they will be put to sleep. If you say you are going to adopt/foster and don’t it could be that dogs life because everyone thought they were safe. If you change your mind that okay but please be respectful and cancel your appointment so we have time to try and find a new home.

Next AM. A few hours of sleep and a dog walk, I figured out some of the problems above. had to control alt del out of xdm and drop down to init 3 to kill some processes that were running. then, use a better syntax on the tar command:
tar -cvf badboot2.tar /boot
bzip2 badboot2.tar gives me a badboot2.tar.bz2 file
which i then place in a dir i call iso_dir
mkisofs -o badboot2tarbz2.iso dir_iso
then had to hard reboot the system to get ANY gui to run. After rebooting and launching init 5 (with complaints from the shell about the kernel being corrupted with an unsupported dev hdc), I launched kd3, and successfully burned the badboot2tarbz2.iso onto a CD. Trumpets sounded again!!!!

cdrecord -scanbus now gives me the following output, recognizing my CD-RW device.

Cdrecord-Clone 2.01 (i686-suse-linux) Copyright (C) 1995-2004 Jörg Schilling
Note: This version is an unofficial (modified) version
Note: and therefore may have bugs that are not present in the original.
Note: Please send bug reports or support requests to
Note: The author of cdrecord should not be bothered with problems in this version.
Using libscg version ‘schily-0.8’.
0,0,0 0) ‘HL-DT-ST’ ‘CD-RW GCE-8080N ‘ ‘2.06’ Removable CD-ROM
0,1,0 1) *
0,2,0 2) *
0,3,0 3) *
0,4,0 4) *
0,5,0 5) *
0,6,0 6) *
0,7,0 7) *

So, trying a more ambitious backup of the whole filesystem. I go up from root, tar -cvf backup_questfs.tar (a 2.42 GB file is created), then bzip2 backup_questfs.tar to make a 864MB file, and finally mkisofs -o backup_questfstarbz2.iso iso to create a 864MB file (this is going to unfortunately take 2 CDs to backup. If I had known this, I would have selected a little less to backup, just to get it all on 1 CD. But anyway, it’s done, and it took a little while, so we are not going to repeat it.)

This was a nice thought, but i ended up doing things the long way, anyway. Probably just this one time. I’ll write a script to handle this in the future. It turns out that cdrecord and hence k3b won’t handle files that won’t fit onto a single CD. Not sure why. It wouldn’t seem to be that hard to do. Anyway, I ended up keeping the original iso to play with getting this to work, and generating 2 new ones by separating my file system into /usr (disk 2/2: 530.1 MB) and /everything else (disk 1/2: 306 MB). i also individually tared the directories to get a feel for their compressed sizes. Here is the list.
total 313332
drwxr-xr-x 22 root root 680 Jul 23 00:53 ..
drwxr-xr-x 2 root root 560 Jul 23 00:24 .
-rw-r–r– 1 root root 649480 Jul 23 00:18 root.tar.bz2
-rw-r–r– 1 root root 3380575 Jul 23 00:14 etc.tar.bz2
-rw-r–r– 1 root root 3206860 Jul 23 00:10 boot.tar.bz2
-rw-r–r– 1 root root 110 Jul 23 00:09 mnt.tar.bz2
-rw-r–r– 1 root root 449484 Jul 23 00:08 srv.tar.bz2
-rw-r–r– 1 root root 2692314 Jul 23 00:06 bin.tar.bz2
-rw-r–r– 1 root root 4106966 Jul 23 00:05 sbin.tar.bz2
-rw-r–r– 1 root root 28148 Jul 22 23:59 sys.tar.bz2
-rw-r–r– 1 root root 583 Jul 22 23:57 media.tar.bz2
-rw-r–r– 1 root root 9793 Jul 22 23:56 home.tar.bz2
-rw-r–r– 1 root root 177662489 Jul 22 23:51 opt.tar.bz2
-rw-r–r– 1 root root 20900088 Jul 22 23:41 var.tar.bz2
-rw-r–r– 1 root root 75327584 Jul 22 23:12 proc.tar.bz2
-rw-r–r– 1 root root 31846533 Jul 22 23:07 lib.tar.bz2
-rw-r–r– 1 root root 83939 Jul 22 23:05 dev.tar.bz2
-rw-r–r– 1 root root 160293 Jul 22 23:03 tmp.tar.bz2
total 543022
drwxr-xr-x 23 root root 696 Jul 23 00:55 ..
drwxr-xr-x 2 root root 80 Jul 23 00:54 .
-rw-r–r– 1 root root 555509945 Jul 22 23:38 usr.tar.bz2

Errors were generated on /proc and /sys directories during the tar process (files were apparently incompletely read and substituted with 0s). Backing up the iso worked through k3b for the smaller files. Interesting that the 2 isos don’t add up in size to the original iso (864.6 MB): their sum is slightly less. Burning the CDs worked either through K3b or in command mode with:
cdrecord -v dev=0,0,0 /*.iso
provided that the cd media was properly read into the scsi table. need to umount /media/cdrecorder and then mount /media/cdrecorder again every time a disk is inserted, and press on the bay to make sure the module has good contact. xterm should read “ATAPI device read”.

so, i tested everything out to make sure that i could read the cd back in using this post as a guide:
mounting the cdrom as /dev/hdc (output from the dmesg command), and mounting with:
mount /mount/cdrom -t -iso9660 -r /dev/hdc
looking at df, it is properly mounted, at which point:
ls /mount/cdrom yields the directory of files, and they can be copied (cp), and extracted using the tar -xvf command in the newly created directory where you want them. Also, the CDROM is now visible through the gui, and everything can be seemlessly opened and extracted just with point and click in the gui.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s