Author: Infong
Date: 02 Nov 2011
Category: os
Comments
I installed postfix and got this error:
postdrop: warning: unable to look up public/pickup: No such file or directory.
Turns out that sendmail was previously installed and that was messing things up. I had to stop sendmail and make the appropriate directory and restart postfix.
Specifically:
mkfifo /var/spool/postfix/public/pickup
ps aux | grep mail
kill
sudo /etc/init.d/postfix restart
Author: Infong
Date: 02 Nov 2011
Category: os
Comments
When we operating partition on Linux (such as delete partitions, create partition, change partition sizes), the partition number is not in accordance with the disk partition.
As my disk partition, it’s the case above. As normal, the partition ‘/dev/sda2’ should be ‘/dev/sda3’, ‘/dev/sda3’ should be ‘/dev/sda4’ and ‘/dev/sda4’ should be ‘/dev/sda2’, the extended partition needn’t change.
Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders, total 625142448 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: 0xa9943039
Device Boot Start End Blocks Id System
/dev/sda1 * 63 39070079 19535008+ 83 Linux
/dev/sda2 132825420 234522623 50848602 83 Linux
/dev/sda3 234522624 625141759 195309568 83 Linux
/dev/sda4 39070080 132825419 46877670 5 Extended
/dev/sda5 39070143 42973874 1951866 82 Linux swap / Solaris
/dev/sda6 42973938 44933804 979933+ 83 Linux
/dev/sda7 44933868 74236364 14651248+ 83 Linux
/dev/sda8 74236428 93755339 9759456 83 Linux
/dev/sda9 93755403 132825419 19535008+ 83 Linux
Partition table entries are not in disk order
SO, how to fix this issue?
There are two ways at this time:
-
Use command ‘f’ under fdisk:
# fidsk /dev/sda
Command (m for help): x #(extra functionality)
Expert command (m for help): f #(fix partition order)
Expert command (m for help): w #(write table to disk)
-
Rebuild partition table
Recommended to use testdisk, is a good partition table recovery program, on how to rebuild the partition table using testdisk, please Google to get related-information.
After fix the partition order, we should modify /etc/fstab and /boot/grub/menu.lst, so the system can find the correct partition after next reboot.
Author: Infong
Date: 02 Oct 2011
Category: os
Comments
Some FreeBSD command.
Add a new user:
adduser USERNAME
Add a new group:
pw groupadd GROUPNAME
Add user to group:
pw groupmod GROUPNAME -m USERNAME
Show group information:
pw groupshow GROUPNAME
Delete a user:
pw userdell USERNAME || pw userdell UID || rmuser username
If you want to use ‘su -’ to root, we should add the user to group ‘wheel’.
By default, root does not allow login with SSH, if you want to allow root login, you should modify ‘/etc/ssh/sshd_config’ as follow:
PermitRootLogin yes
PasswordAuthentication yes
AllowUsers root
Author: Infong
Date: 29 Sep 2011
Category: os
Comments
A while ago I thought it would be a good idea to make a backup of my Linux server by just dumping the complete disk to a file. In retrospect, it would have been much easier had I just dumped the individual filesystems.
When I finally got around to using this backup, long after the 10GB disk had perished I realized that to use the loopback device to mount a filesystem it actually needs a filesystem to mount. What I had was a disk image, including partition table and individual partitions. To further complicate matters the data partition was also not the first partition inside this image.
For reference, I created this image using the Unix “dd” tool:
$ sudo dd if=/dev/had of=hda.img
30544113+0 records in
30544113+0 records out
$ sudo ls -lh
-rw-r--r-- 1 root root 9.6G 2008-01-22 14:12 hda.img
I followed the instructions on http://www.trekweb.com/~jasonb/articles/linux_loopback.html to try and mount the partitions inside the disk image, but ran into two problems.
To mount a partition inside the disk image you need to calculate the offset of where the partition starts. You can use fdisk to show this information to you, but you need to specify the number of cylinders if you are using a disk image.
You then also need to multiply the start and end numbers with the calculated sectors to get a byte offset.
I found another tool more useful for this task, called parted. If you are using Ubuntu, you can install it with “apt-get install parted”
$ sudo parted hda.img
GNU Parted 1.7.1
Using /data/rabbit/disk_image/test2
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit
Unit? [compact]? B
(parted) print
Disk /data/rabbit/disk_image/test2: 10262568959B
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 32256B 106928639B 106896384B primary ext3 boot
2 106928640B 1184440319B 1077511680B primary linux-swap
3 1184440320B 10256924159B 9072483840B primary ext3
(parted) quit
Now we have the offsets and we can use those to mount the filesystems using the loopback device:
$ mount -o loop,ro,offset=32256 hda.img /mnt/rabbit
That mounted the first partition, the “boot” partition, but this didn’t have the data on it that I was looking for. Lets try to mount partition number 3.
$ sudo umount /mnt/rabbit
$ sudo mount -o loop,ro,offset=1184440320 test2 /mnt/rabbit
$ sudo mount: wrong fs type, bad option, bad superblock on /dev/loop0,
missing codepage or helper program, or other error In some cases useful info is found in syslog - try dmesg | tail or so
Oops, that doesn’t look right. According the article referred to above if you are using a util-linux below v2.12b then you cannot specify an offset higher than 32bits. I’m using util-inux 2.13 which shouldn’t have that problem, and besides, my offset is well below the 32bit limit.
The article also offers an alternative loopback implementation that supports mounting partitions within an image, but that requires patching and recompiling your kernel which I would rather not do.
Instead I decided to extra ct the filesystem from the image which would then allow me to mount it without specifying an offset. Doing this is quite straightforward with “dd”. You need to give “dd” a skip count, or, how far into the source to start copying, and a count, how much to copy.
Here you can either use the single byte offsets retrieved with parted or divide them by 512 and let “dd” use 512 byte blocks. Copying just one byte at a time takes a very long time, so I suggest using a larger block size.
Here is the command I used to extract my filesystem. Skip is 2313360 (1184440320/512) and Count is 17719695 (9072483840/4)
$ sudo dd if=hda.img of=hda3.img bs=512 skip=2313360 count=17719695
17719695+0 records in
17719695+0 records out
9072483840 bytes (9.1 GB) copied, 485.679 seconds, 18.7 MB/s
After extracting the filesystem I was able to mount it without any problems.
$ sudo mount -o loop hda3.img /mnt/rabbit/
$ sudo df -h /mnt/rabbit
Filesystem Size Used Avail Use% Mounted on
/data/rabbit/image/hda3.img
8.4G 6.3G 1.7G 80% /mnt/rabbit
Author: Infong
Date: 26 Sep 2011
Category: virtualizationos
Comments
I’ve got some problems when upgrading the kernel on my VPS:
warning: grub-probe can't find drive for /dev/xvda. grub-probe: error: cannot stat `/dev/xvda'. run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 1
So I have resolved this problem like this:
-
First let’s create /dev/xvda block device:
$ sudo mknod /dev/xvda b 202 0
-
Edit /boot/grub/device.map file:
Change
(hd0) /dev/sda
To
(hd0) /dev/xvda
-
Edit /usr/sbin/update-grub file:
Change
find_device ()
{
if ! test -e ${device_map} ; then
echo quit | grub --batch --no-floppy --device-map=${device_map} > /dev/null
fi
grub-probe --device-map=${device_map} -t device $1 2> /dev/null
}
to
find_device ()
{
if ! test -e ${device_map} ; then
echo quit | grub --batch --no-floppy --device-map=${device_map} > /dev/null
fi
#grub-probe --device-map=${device_map} -t device $1 2> /dev/null
echo /dev/xvda
}
-
Run update-grub 0
-
Assuming your root disk is /dev/xvda1, run:
sed -i "s/xvda/xvda1/g" /boot/grub/menu.lst
The run ”apt-get upgrade
” now.
Author: Infong
Date: 25 Sep 2011
Category: spl
Comments
When I was checking my server’s apache error log, I found many warning about ‘open_basedir’ like:
2011/09/25 21:27:54 [error] 3927#0: *146 FastCGI sent in stderr: "PHP Warning: require(): open_basedir restriction in effect. File() is not within the allowed path(s): (/srv/http/:/home/:/tmp/:/usr/share/pear/) in /srv/http/xxx.php on line 913″ while reading upstream, client: x.x.x.x, server: xxxxx.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm.sock:", host: "xxxxx.com", referrer: "http://xxxxx.com/"
I tried everything including setting setting open_basedir. It stopped working if I activated the open_basedir protection and started working if I removed it. After doing some research, I looked into the wrong direction – the problem was not php but eAccelerator. After I found that out it was easy to get to the solution, you need to compile it with the option –without-eaccelerator-use-inode, like this:
$ cd /PATH/TO/eaccelerator-$VERSION
$ make clean
$ ./configure --enable-eaccelerator=shared --without-eaccelerator-use-inode
$ make
$ sudo make install
After re-compiling and installing, make sure you clear out the existing eAccelerator files before restarting webserver:
$ sudo rm -rf /var/cache/eaccelerator/*
$ sudo /etc/rc.d/httpd restart
OK, everything became quiet again.
Reference:
- http://eaccelerator.net/ticket/414
- http://eaccelerator.net/ticket/104