Monday, August 30, 2010

Note about permissions in VirtualBox physical hard disk usage in Linux host

From VirtualBox manual: "Starting with version 1.4, as an alternative to using virtual disk images, VirtualBox can also present either entire physical hard disks or selected partitions thereof as virtual disks to virtual machines...
...this type of access is called "raw hard disk access"; it allows a guest OS to access its virtual hard disk without going through the host OS file system."
Do read the manual (part 9.7.1 at now) and do it at your own risk! Here we will talk only about permission problem you can get in Linux host. That, you will need read/write access for the entire disk (or selected partitions). For example:

$ VBoxManage internalcommands createrawvmdk -filename $HOME/.VirtualBox/HardDisks/sda2.vmdk -rawdisk /dev/sda -partitions 2

set up an image for access /dev/sda2 in Linux host. User needs read/write access to this partition. Otherwise, we will get some messages like this while adding sda2.vmdk to a virtual machine:

NS_ERROR_FAILURE (0x80004005)
Component: 
HardDisk
Interface: 
IHardDisk {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
Callee: 
IVirtualBox {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}

Check the physical disks properties:

$ ls -l /dev/sda*

brw-rw---- 1 root disk 8, 0 2010-08-30 21:53 /dev/sda
brw-rw---- 1 root disk 8, 1 2010-08-30 12:22 /dev/sda1
brw-rw---- 1 root disk 8, 2 2010-08-30 21:31 /dev/sda2
brw-rw---- 1 root disk 8, 5 2010-08-30 12:22 /dev/sda5

We can see one solution to grant permissions is adding username to the disk group, for example, by editing /etc/group file. And don't forget to re-login.

Friday, August 27, 2010

Very short about using transmission-daemon

The transmission-daemon program is a daemon-based Transmission session that can be controlled via IPC commands by transmission-remote(1) [1]. This program is used by default in FreeNAS, and maybe you want to use it on Linux box. It's very likely you distribution come with transmission by default. In that case, you need to install transmission-daemon only:

# apt-get install transmission-daemon


Configuration file is /var/lib/transmission-daemon/info/settings.json (it's quiet safe to add *.*.*.* to rpc-whitelist option). After editing (user, password, paths, etc), we need to reload the daemon itself:

# /etc/init.d/transmission-daemon reload

Using remote client was discussed before [2].
Note: transmission-daemon configuration is very well documented on this web site. You are recommended to read (at least to feel the power of FreeNAS's web interface).

1. man transmission-daemon
2. Cross-platform transmission-remote-gui

Sunday, August 22, 2010

Boot from USB Flash Without BIOS Support Using Plop via GRUB2

As result of an accident the netbook has gone to the heaven in the crisis time, so I've turned FreeNAS box to a normal PC with dual boot (Linux and FreeNAS) for working. Unfortunately, the DVD ROM has gone to the heaven, too. There are not to much options:
  1. Dual boot, each OS on their disk. Needs 2 devices, not my case.
  2. Dual boot on the same disk, still available, but requires skill and time [1].
  3. Boot FreeNAS from USB stick.
The last choice is the most convenient, but BIOS doesn't support booting from USB. Fortunately, there are boot managers, which fill this hole. Plop [2] has many features, many options and well-documented, so I chose it.
The system is running Linux, booted via GRUB2. If you like me don't want to destroy GRUB(2), you can run Plop from GRUB(2). You need to download the program, unzip and copy the boot manager binary program plpbt.bin to /boot, then add the following entry to GRUB2 configuration file (/boot/grub/grub.cfg):

# Boot Plop Boot Manager
menuentry "Plop Boot Manager" {
set root='(hd0,3)' #Change to your boot partition
linux16 /boot/plpbt.bin
}

Hold down Shift key while GRUB2 is booting to get its menu, then you can run Plop, from where FreeNAS on USB Flash can be booted.

See [3] for FreeNAS installation on USB Flash. Get the "embedded" (img) file instead of iso.

P.S. of course this is temporary solution. The better is CF to IDE adapter usage.

1. FreeNAS forum on sf.net
2. Plop boot manager
3. FreeNAS USB installation

Friday, August 20, 2010

Disable unused console (tty) when using Upstart init daemon

There are not /etc/inittab anymore, but /etc/init/ttyN.conf (N from 1 to 6). Just comment out the last line in each file you desire. For example (in /etc/init):

$ cat tty1.conf
# tty1 - getty
#
# This service maintains a getty on tty1 from the point the system is
# started until it is shut down again.

start on stopped rc RUNLEVEL=[2345]
stop on runlevel [!2345]

respawn
exec /sbin/getty -8 38400 tty1

$ cat tty1.conf | wc -l
10

$ sed -i '10 s/^/#/' tty{2,3,4,5,6}.conf

Please tell me other command lines to do the last job.
P.S. in an Ubuntu box Ctrl+Alt+Backspace now is Right Alt (Alt Gr) + Print Screen + k.

Wednesday, August 18, 2010

Boot System Rescue CD from ISO image on the disk with Grub2

"SystemRescueCd is a (Gentoo) Linux system rescue disk available as a bootable CD-ROM or USB stick for administrating or repairing your system and data after a crash." The latest version include many administration tool of both CLI and GUI. If you frequently use SystemRescueCd, you may want to boot it directly from Grub2.
From version 2 GRUB can provide the GREAT loopback option, in co-junction with whom some Linux Live CD distributions (grml, SystemRescueCd, etc) provide direct boot (iso9660) ISO via their options — isofrom, findiso, isoloop and some others. Option isoloop is only supported in SystemRescueCd from version 1.4.0.
The ISO is in (hd0,3)/ISOs/. grub.cfg has the following entry:

# Boot system rescue CD from ISO
menuentry "System Rescue CD from ISO" {
loopback loop (hd0,3)/ISOs/res-1.5.8.iso
linux (loop)/isolinux/rescuecd isoloop=/ISOs/res-1.5.8.iso setkmap=us
initrd (loop)/isolinux/initram.igz
}

grub.cfg contains the global option set root='(hd0,3)', so boot script will search the ISO image in /dev/sda3 partition in the path specified after isoloop option.

Read more:
1. Boot the SystemRescueCD ISO image from the disk using Grub2
2. Boot an ISO via Grub2
3. MultiBoot USB with Grub2 (boot directly from iso files)

Wednesday, March 03, 2010

smartctl -a /dev/ad0

My 250 GB hard disk has gone...

FreeNAS log:
kernel: ad0: FAILURE - READ_DMA48 status=51 error=40 LBA=445600994
kernel: g_vfs_done():ad0p1[READ(offset=228147691520, length=16384)]error = 5

SMART output:

$ smartctl -a /dev/da0
smartctl version 5.38 [i386-portbld-freebsd7.2] Copyright (C) 2002-8 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

=== START OF INFORMATION SECTION ===
Model Family: Seagate Barracuda 7200.9 family
Device Model: ST3250824A
Serial Number: 3ND0Y5G1
Firmware Version: 3.AAH
User Capacity: 250,059,350,016 bytes
Device is: In smartctl database [for details use: -P show]
ATA Version is: 7
ATA Standard is: Exact ATA specification draft version not indicated
Local Time is: Wed Mar 3 15:30:28 2010 MSK
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status: (0x82) Offline data collection activity
was completed without error.
Auto Offline Data Collection: Enabled.
Self-test execution status: ( 0) The previous self-test routine completed
without error or no self-test has ever
been run.
Total time to complete Offline
data collection: ( 430) seconds.
Offline data collection
capabilities: (0x5b) SMART execute Offline immediate.
Auto Offline data collection on/off support.
Suspend Offline collection upon new
command.
Offline surface scan supported.
Self-test supported.
No Conveyance Self-test supported.
Selective Self-test supported.
SMART capabilities: (0x0003) Saves SMART data before entering
power-saving mode.
Supports SMART auto save timer.
Error logging capability: (0x01) Error logging supported.
General Purpose Logging supported.
Short self-test routine
recommended polling time: ( 1) minutes.
Extended self-test routine
recommended polling time: ( 100) minutes.

SMART Attributes Data Structure revision number: 10
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x000f 107 095 006 Pre-fail Always - 13692759
3 Spin_Up_Time 0x0003 092 088 000 Pre-fail Always - 0
4 Start_Stop_Count 0x0032 100 100 020 Old_age Always - 342
5 Reallocated_Sector_Ct 0x0033 100 100 036 Pre-fail Always - 0
7 Seek_Error_Rate 0x000f 075 060 030 Pre-fail Always - 38432019
9 Power_On_Hours 0x0032 100 100 000 Old_age Always - 767
10 Spin_Retry_Count 0x0013 100 100 097 Pre-fail Always - 0
12 Power_Cycle_Count 0x0032 100 100 020 Old_age Always - 364
187 Reported_Uncorrect 0x0032 001 001 000 Old_age Always - 1812
189 High_Fly_Writes 0x003a 100 100 000 Old_age Always - 0
190 Airflow_Temperature_Cel 0x0022 060 056 045 Old_age Always - 40 (Lifetime Min/Max 33/40)
194 Temperature_Celsius 0x0022 040 044 000 Old_age Always - 40 (0 19 0 0)
195 Hardware_ECC_Recovered 0x001a 059 051 000 Old_age Always - 76090870
197 Current_Pending_Sector 0x0012 100 100 000 Old_age Always - 2
198 Offline_Uncorrectable 0x0010 100 100 000 Old_age Offline - 2
199 UDMA_CRC_Error_Count 0x003e 200 200 000 Old_age Always - 0
200 Multi_Zone_Error_Rate 0x0000 100 253 000 Old_age Offline - 0
202 TA_Increase_Count 0x0032 100 253 000 Old_age Always - 0

SMART Error Log Version: 1
ATA Error Count: 1817 (device log contains only the most recent five errors)
CR = Command Register [HEX]
FR = Features Register [HEX]
SC = Sector Count Register [HEX]
SN = Sector Number Register [HEX]
CL = Cylinder Low Register [HEX]
CH = Cylinder High Register [HEX]
DH = Device/Head Register [HEX]
DC = Device Command Register [HEX]
ER = Error register [HEX]
ST = Status register [HEX]
Powered_Up_Time is measured from power on, and printed as
DDd+hh:mm:SS.sss where DD=days, hh=hours, mm=minutes,
SS=sec, and sss=millisec. It "wraps" after 49.710 days.

Error 1817 occurred at disk power-on lifetime: 767 hours (31 days + 23 hours)
When the command that caused the error occurred, the device was active or idle.

After command completion occurred, registers were:
ER ST SC SN CL CH DH
-- -- -- -- -- -- --
40 51 00 e8 54 8f 40 Error: UNC at LBA = 0x008f54e8 = 9393384

Commands leading to the command that caused the error were:
CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name
-- -- -- -- -- -- -- -- ---------------- --------------------
25 00 20 e2 54 8f 40 00 03:27:10.863 READ DMA EXT
b0 d1 01 01 4f c2 e0 00 03:27:08.976 SMART READ ATTRIBUTE THRESHOLDS [OBS-4]
25 00 20 e2 54 8f 40 00 03:27:08.944 READ DMA EXT
b0 d0 00 00 4f c2 e0 00 03:27:07.057 SMART READ DATA
25 00 20 e2 54 8f 40 00 03:27:06.984 READ DMA EXT

Error 1816 occurred at disk power-on lifetime: 767 hours (31 days + 23 hours)
When the command that caused the error occurred, the device was active or idle.

After command completion occurred, registers were:
ER ST SC SN CL CH DH
-- -- -- -- -- -- --
40 51 00 e8 54 8f 40 Error: UNC at LBA = 0x008f54e8 = 9393384

Commands leading to the command that caused the error were:
CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name
-- -- -- -- -- -- -- -- ---------------- --------------------
25 00 20 e2 54 8f 40 00 03:27:04.672 READ DMA EXT
b0 d0 00 00 4f c2 e0 00 03:27:08.976 SMART READ DATA
25 00 20 e2 54 8f 40 00 03:27:08.944 READ DMA EXT
b0 da 00 00 4f c2 e0 00 03:27:07.057 SMART RETURN STATUS
ca 00 0c 22 2f 00 e0 00 03:27:06.984 WRITE DMA

Error 1815 occurred at disk power-on lifetime: 767 hours (31 days + 23 hours)
When the command that caused the error occurred, the device was active or idle.

After command completion occurred, registers were:
ER ST SC SN CL CH DH
-- -- -- -- -- -- --
40 51 00 e8 54 8f 40 Error: UNC at LBA = 0x008f54e8 = 9393384

Commands leading to the command that caused the error were:
CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name
-- -- -- -- -- -- -- -- ---------------- --------------------
25 00 20 e2 54 8f 40 00 03:27:04.672 READ DMA EXT
b0 da 00 00 4f c2 e0 00 03:27:04.672 SMART RETURN STATUS
ca 00 0c 22 2f 00 e0 00 03:27:04.672 WRITE DMA
ca 00 20 02 2f 00 e0 00 03:27:07.057 WRITE DMA
ca 00 04 a2 00 00 e0 00 03:27:06.984 WRITE DMA

Error 1814 occurred at disk power-on lifetime: 767 hours (31 days + 23 hours)
When the command that caused the error occurred, the device was active or idle.

After command completion occurred, registers were:
ER ST SC SN CL CH DH
-- -- -- -- -- -- --
40 51 00 e8 54 8f 40 Error: UNC at LBA = 0x008f54e8 = 9393384

Commands leading to the command that caused the error were:
CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name
-- -- -- -- -- -- -- -- ---------------- --------------------
25 00 20 e2 54 8f 40 00 03:27:04.672 READ DMA EXT
35 00 20 22 19 34 40 00 03:27:04.672 WRITE DMA EXT
35 00 20 02 19 34 40 00 03:27:04.672 WRITE DMA EXT
35 00 20 e2 18 34 40 00 03:27:04.671 WRITE DMA EXT
35 00 20 c2 18 34 40 00 03:27:04.671 WRITE DMA EXT

Error 1813 occurred at disk power-on lifetime: 767 hours (31 days + 23 hours)
When the command that caused the error occurred, the device was active or idle.

After command completion occurred, registers were:
ER ST SC SN CL CH DH
-- -- -- -- -- -- --
40 51 00 e8 54 8f 40 Error: UNC at LBA = 0x008f54e8 = 9393384

Commands leading to the command that caused the error were:
CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name
-- -- -- -- -- -- -- -- ---------------- --------------------
25 00 20 e2 54 8f 40 00 03:26:51.227 READ DMA EXT
25 00 20 e2 bc 40 40 00 03:26:51.227 READ DMA EXT
ec 00 00 00 00 00 e0 00 03:26:51.226 IDENTIFY DEVICE
25 00 20 e2 54 8f 40 00 03:26:51.226 READ DMA EXT
c8 00 20 62 55 1d e5 00 03:26:51.226 READ DMA

SMART Self-test log structure revision number 1

SMART Selective self-test log data structure revision number 1
SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS
1 0 0 Not_testing
2 0 0 Not_testing
3 0 0 Not_testing
4 0 0 Not_testing
5 0 0 Not_testing
Selective self-test flags (0x0):
After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

Tuesday, February 23, 2010

How to secure your FreeNAS server

This summary is not available. Please click here to view the post.