Tuesday, January 20, 2015

Formatting USB Flash Drive on Linux


Formatting USB Flash Drive on Linux


Under UNIX-like operating systems, formatting a USB flash drive, in fact even a hard drive, requires knowing the file name for the partition that is to be formatted. These are files under the /dev directory, like for example, /dev/sdb1. So the interesting question to be asked is how does one come to know of the file representing the partition on the device? Immediately after connecting a USB flash drive to my laptop running Arch Linux and looking at the last few lines of ‘dmesg’ output gives:

sd 4:0:0:0: [sdb] 31703040 512-byte logical blocks: (16.2 GB/15.1 GiB)

Notice the ‘sdb’ within square brackets. This hints that the device file would start with /dev/sdb. Further, running:

$ ls -l /dev/sdb*
brw-rw---- 1 root disk 8, 16 Jan 31 23:55 /dev/sdb
brw-rw---- 1 root disk 8, 17 Jan 31 23:49 /dev/sdb1

And keeping it mind that it is a partition that is formatted, confirms the file that we are searching to be /dev/sdb1. Now, for formatting, if it is the EXT4 filesystem that is to be built then run:

mkfs.ext4 -L <label> /dev/sdb1

Use of the  -L <label> switch is optional. It gives a fancy name to the device that is often visible when automounting in a desktop environment like KDE or GNOME. After the above commands successful termination, one might want to print the partition table on the device for assurance:

# parted /dev/sdb print
Model: JetFlash Transcend 16GB (scsi)
Disk /dev/sdb: 16.2GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
1      16.4kB  16.2GB  16.2GB  primary  ext4         boot, lba

Notice that in the above case, the complete device (/dev/sdb) was given to parted and not just one partition. Manual mounting can be as simple as:

mount -t ext4 /dev/sdb1 <dir>

For more information, on Arch Linux, consider reading the man pages of dmesg(1),  mkfs(8), mount(8) and parted(8).

Sunday, January 18, 2015

Resolving "The User Profile Service failed the logon. User profile cannot be loaded."

Resolving "The User Profile Service failed the logon. User profile cannot be loaded."


Steps

Appears while attempting to logon in Windows Vista, 2008, 2008 R2 and 7.
Exact cause is unknown, but this issue may occur if the user profile was manually deleted by using the command prompt or Windows Explorer by a user or by some program. A profile that is manually deleted does not remove the security identifier (SID) from the user profile list in the registry. Since the SID is still present, Windows will still try to load the profile by using the ProfileImagePath that points to a nonexistent path. Therefore, the profile cannot be loaded.
This can also be a issue with the user profile entering into a backup state, or if the C:\Users\(User Name) user profile folder is manually renamed.
1.

Log on to the Computer

Log on to the computer using the Administrator (or an Administrator-level) account.
If the computer is not joined to a domain, reboot it and start your computer in safe mode, then log on using the Administrator (or an Administrator-level) account.
2.

Trawl through the Registry

Open the Start menu. In the Start Search area, type regedit and press Enter (if prompted by UAC, click Continue/Yes). In regedit, go to: 
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
Expand the ProfileList key and look for the SID key (named "S-1-5"...) with a long number that ends in ".bak". Click it, and look at the ProfileImagePath value in the right pane to verify that this is the user account profile that has the error.
a) If you have two SID keys with the same number (with one ending in ".bak" and one showing the affected user account in the ProfileImagePath value), continue to Step 3; 
b) If you have just one SID key with the ProfileImagePath value showing the affected user account, proceed to Step 4.
3.

Two SID keys with the same number

a) Of the two SID keys that corresponds to the affected user account, right-click the SID key that does NOT end in ".bak" and click Rename. 
b) Add .bk to the end of the numbers and press Enter. 
c) Right-click the other SID key that DOES end in ".bak" and click Rename. 
d) Remove only .bak from the end of the numbers (so that it has the same name as the other SID key did before you renamed it) and press Enter. 
e) Now go back and Rename the first one with .bk to .bak now at the end of the numbers and press Enter.
Proceed to Step 5...
4.

Only one SID key ending in ".bak"

a) Right-click the SID key that corresponds to the affected user account and click Rename. 
b) Remove only .bak from the end of the numbers, and press Enter. 
c) In the right pane, right-click the RefCount value (if none exists, right-click the right pane and click New and DWORD (32 bit) Value, then type RefCount and press Enter), and click Modify. 
d) Type 0 into the Value Data textbox and click OK. 
e) In the right pane, right-click the State value and click Modify. 
f) Type 0 into the Value Data textbox and click OK.
5.

Try logging on again!

Close regedit and restart the computer. You should be able to logon now...