Wednesday, December 17, 2008

Of Flash drives and Windows XP...Part II

Part I can be found here.

This part contains the workarounds !

How to fool Windows into thinking that the removable drive is a local disk :

This solution has been copied from here

I am posting the solution here too, just because its difficult to find the solution on that page :P.

Nearly all USB flash drives pretend to have a removable media (even it's a lie), so Windows detects them as 'removable'. On drives with a removable media Windows 2000 and higher supports only one partition.
Finally it's a single bit in the device's device descriptor, the removable media bit (RMB). If you take away the RMB then Windows sees the drive as 'local disk' and multiple partitions work.
The Removable Media Bit can be changed either in the drive's hardware or by a Windows filter driver.
Changing in the hardware works with some flash drives by means of the tool Lexar BootIt.

But this works only with some pen-drvies. It DID NOT work for me.

The second way to do this ...

A filter driver for removing the RMB has been made by Hitachi for their Microdrives (Compatct Flash cards with a mini harddrive):

xpfildrvr1224_320.zip

By modifying the included INF file the filter driver can be used with any other 'removable' drive.
For the device detection there are the lines in section [cfadisk_device]:

[cfadisk_device]
%Microdrive_devdesc% = cfadisk_install,IDE\DiskIBM-DSCM-11000__________________________SC2IC801

"IDE\DiskIBM-DSCM-11000__________________________SC2IC801" is the device ID of one of the supported Microdrives.

In analogy to these lines we add one line for each 'removable' USB drive we want to turn into an USB hard drive. The ID is found in the Windows device management: Expand 'Disk drives', right click your USB drive, select Properties. On the tab "Details" under XP the item "Device instance ID" is already selected. Click on the ID in the List and press Ctrl+C, this copies the ID into the Windows Clipboard and can be pasted somewhere else with Ctrl+V.
XP shows the tab "Details" only when the environment variable DEVMGR_SHOW_DETAILS=1 is set:
DevMgr_Show_1.reg download and doubleclick the file, then relogon to take effect.

Sample:
USBSTOR\DISK&VEN_LEXAR&PROD_JUMPDRIVE&REV_1.30\K326441127040&0
We need the fat part:

[cfadisk_device]
%Microdrive_devdesc% = cfadisk_install,USBSTOR\DISK&VEN_LEXAR&PROD_JUMPDRIVE&REV_1.30

In the last line of the INF file we change "Hitachi Microdrive" into something nice as "RemovableToFixed".

In the device manager again right-click the USB drive, "Update driver...", then "No, not this time" -> Next -> "Install from a list or..." -> Next -> "Don't search." -> Next -> "Have Disk" -> browse to the INF file here. Now "RemovableToFixed" should be in the list -> Next -> Confirm the two warnings -> Finish.
Now the drive is re-detected, actually as USB hard drive. The drive can be partitioned, and all the existing partitions are visible and usable.

Now, this solution works with all the USB flash drives. But the problem is that since this method requires installing a custom driver, the pen-drive is detected as a local disk only on the machine that uses that driver. All the other machines detect it as a removable drive. This essentially defeats the purpose of using a pen-drive !!

Re-arrangement of partitions :

This hasn't been copied from anywhere :P.

What i realized was that only the 1st physical partition was being assigned a letter. So i re-arranged the partitions within the flash drive as follows :

1) 2111 MB NTFS (for general use)
2)1024 MB ext2 ( for persistence)
3)700 MB FAT32, bootable.

This made the NTFS partition visible from Windows and i could use my flash drive as if it were a ~2 GB pen-drive.

Looking back, I actually liked this solution, since, whenever I use my pen-drive in the college, the viruses wont be able to mess up the FAT32 bootable partition ! and when I use Linux, all 3 partitions are being mounted anyway. The flip side was that sharing data between the partitions was impossible with Windows XP.....

So as it turned out, there is no concrete solution to using Flash drives with multiple partitions with Windows XP....just some workarounds, each with its pros and cons....

So what do you do if you wanna use a Flash drive with multiple partitions ? .....Use Linux :-)

Of Flash drives and Windows XP...Part I

As mentioned here, I faced quite an annoying problem when i created multiple partitions on my USB flash drive.

The layout of the Flash drive was as follows :

1)720 MB partition, FAT32, bootable
2)1024 MB partition ext2 (for persistence)
3)2111 MB parition, NTFS (for general use)

Now, the problem was that when the Flash drive was inserted when Windows XP was running, only 1 partition was being assigned a letter by Windows. The remaining partitions were visible from the Disk Management Tool, but were not being assigned a letter and as a result were rendered useless.
Any attempt to assign a letter to the drives resulted in the following error :
"The partition is not enabled. To enable the partition re-start the computer."

Restarting the computer does not help and the same error is displayed.
Now this was annoying, because the partition that was being assigned a letter was the 720 MB one, which was already filled up.

This problem is absent in Ubuntu. All the 3 partitions are detected and are usable. This problem is confirmed by Microsoft as a feature (lol :P).Only the first partition on the USB Flash drive is assigned a letter and is usable.

There are a couple of workarounds for this ....one is to fool Windows into thinking that the removable drive is a local disk. The other one involves rearrangement of partitions.

Workarounds can be found here.

Of Live USBs and MBRs

Determined to put my 4 GB flash drive to good use, i decided to create a Live USB disk of the Interpid Ibex on it.

Now, Ubuntu 8.10 comes with this neat "Live USB disk creator" tool, which makes it extremely easy to create a live disk.But on my friend Chinmay's blog, i read that this tool doesn't make the USB stick persistent. So, without trying it out myself, i headed here. Now this page describes how to install Ubuntu 8.10 on the USB stick.

After following all the steps mentioned there, i was unable to boot through my USB stick. It displayed some garbage on the screen and i was forced to restart the computer.

So now, I tried the Live USB creator tool, which led to the same problem as well !. One probable source of this kind of error can be a corrupted MBR. So i tried writing a MBR to the disk using lilo.

#lilo -M /dev/sdX

where, X is the letter assigned to the drive, which can be found out by doing a #fdisk -l .

And, as it turned out, this was the problem. Now, I was able to boot through my USB stick and everything seemed just fine. All the settings and documents were persistent. I again, formatted the USB stick and used the tool provided with the Intrepid, and surprisingly the settings and documents were persistent here too !. So Chinmay's might be an isolated problem....or mine an isolated success :P .

The major difference that i found out between the two methods was that the creator tool does not create separate physical partitions on the stick. It instead creates a file on the stick and uses it for persistent settings. On the other hand, the manual method creates a separate partition for keeping the settings persistent.

Now, my USB stick was ready ! ....well not exactly.....i faced quite an annoying problem in Windows while using this USB stick.

Since I'm running out of time, I will post the problem and some workarounds that I found out later.

Stay tuned :-D


Saturday, December 13, 2008

Problem with user Privileges and Roles in OpenSolaris

Had tried out Open Solaris a few months ago...and straightaway faced a numerous problems :P ...

The most annoying was that the user privileges were getting reset on every login.
So here i am posting how i worked around this problem.

As I said,

The user privileges of my user were getting reset on every login and now, the GUI had started throwing a strange error...when i started the user admin tool ( Users and Groups ), it asked me for authorization, when i provided the root password, it simply rejected it.

The funny part is, that i can "su" root using the same password through the terminal !! (This is ofcourse after i "su" the Primary Administrator) .

So, i was forced to work with the CLI, i tried using the "usermod" command, but I did not understand clearly the way it is supposed to be used, so gave up on that too.


Next, i opened the /etc/user_attr file .

/****************
/etc/user_attr snippet :

root::::type=role;auths=solaris.*,solaris.grant;profiles=All;lock_afte r_retries=no;min_label=admin_low;clearance=admin_high
aditya::::profiles=Prim ary Administrator;roles=root

#amod::::profiles=Apache 22 Administration,Application Server Management,Audit Control,Audit Review,Basic Actions,Console #User,Contract Observer,Cron Management,Crypto Management,DAT Administration,D-BUS Management,Desktop Configuration,Device #Management,Device Security,DHCP Management,dtwm,File System Management,File System Security,FTP Management,HAL #Management,Idmap Name Mapping Management,Idmap Service Management,Inetd Management,Information Security,IP Filter #Management,ISCSI Target Administration,ISCSI Target Management,ISNS Server Management,Kerberos Client Management,Kerberos #Server Management,Log Management,Mail Management,Maintenance and Repair,Media Backup,Media Restore,MySQL #Administration,Name Service Management,Name Service Security,NDMP Management,Network IPsec Management,Network Link #Security,Network Management,Network Security,Network Wifi Management,Network Wifi Security,Object Access #Management,Object Label Management,Operator,Outside Accred,Postgres Administration,Primary Administrator,Printer #Management,Process Management,Project Management,Rights Delegation,Rmvolmgr Management,Service Management,Service #Operator,shutdown,SMBFS Management,SMB Management,Software Installation,System Administrator,System Event Management,User #Management,User Security,VSCAN Management,Web Console Management,ZFS File System Management,ZFS Storage Management,Zone #Management;

amod::::auths=solaris.*,solaris.grant;profiles=All;roles=root

/***** ***************end of snippet

(all the lines of amod (second from last) have been commented, they might not show up properly...formatting problems)

so as u can see, my user (amod) had all the privileges, but they weren't showing up in the GUI ! (bug ?). And now i understood why i couldn't "su" root... i had no "roles" defined. I have no idea of how to set roles through the GUI or the CLI, so instead i just copied "root's" line and made some changes :P

So now, my problem is solved, i can su root directly from amod and do everything i want (heck ! im _almost_ root now :D ).

But, the problem of the GUI not showing the privileges still persists.

I had posted this workaround on the Pune Open Solaris User Group's forums and was suggested that I post it on the Open Solaris desktop-discuss forums. The post on the desktop-discuss forums can be found here. The same problem has been confirmed by 3 users there.
So, until an update for the GUI, which allows roles to be defined is released, the above workaround works just fine :-)

EDIT:
You can also assign roles to a user using the "usermod" command with a "-r" option. I did not know this then. This, again, can be done only by the Primary Admin, if no other users have "root" role defined.