Oops, I am trying to reset root password for a server with Ubuntu 10.04 LTS but the grub menu just doesn't come up. So it turns out the interactive grub menu is disabled since GRUB2. And what we need to do to get into the GRUB menu is to hold the shift key during boot. According official documentation, pressing the ESC key may also display the menu sometime too (Reference here)
So once you get into the menu, move your text cursor to the end of the line starting with "LINUX", append "init=/bin/bash panic=3" and press with CTRL+X to start booting to single user mode.
Once you are booted to single user mode, you will be shown wilt login prompt
root@(none)~#
You could now type "mount -o remount,rw /" to remount / directory to change the root mount from read-only to read-writable. Now you could issue "password" command to update the password on this server.
I am a Linux Administrator in Hong Kong, specialized in RHEL administration as well as IAAS cloud deployment. :-)
2012年2月5日 星期日
2011年12月8日 星期四
Allow Linux VM running on KVM paravirtualized environment to support disk hotplugging
In case you have a Linux OS VM running on KVM paravirtualized environment and found that it doesn't response to the new virtual disk you added (you dont see a new disk on dmesg or nothing coming up from fdisk -l), you will need to make sure virtio_blk driver is in place.
[root@vm ~]# lsmod | grep -i virtio
virtio_net 15665 0
virtio_balloon 4281 0
virtio_blk 5087 3
virtio_pci 6733 0
virtio_ring 7169 4 virtio_net,virtio_balloon,virtio_blk,virtio_pci
virtio 4824 4 virtio_net,virtio_balloon,virtio_blk,virtio_pci
Indeed, you should be seeing /dev/vd* instead of /dev/sd* if you have picked correct OS type during VM initialization. In case you are seeing /dev/sd*, probably you didnt pick correct OS type and that caused virtio associated driver not being loaded.
[root@vm ~]# fdisk -l /dev/vda
Disk /dev/vda: 21.5 GB, 21474836480 bytes
16 heads, 63 sectors/track, 41610 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0006fe0a
Device Boot Start End Blocks Id System
/dev/vda1 * 3 409 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2 409 41611 20765696 8e Linux LVM
Partition 2 does not end on cylinder boundary.
[root@vm ~]# lsmod | grep -i virtio
virtio_net 15665 0
virtio_balloon 4281 0
virtio_blk 5087 3
virtio_pci 6733 0
virtio_ring 7169 4 virtio_net,virtio_balloon,virtio_blk,virtio_pci
virtio 4824 4 virtio_net,virtio_balloon,virtio_blk,virtio_pci
Indeed, you should be seeing /dev/vd* instead of /dev/sd* if you have picked correct OS type during VM initialization. In case you are seeing /dev/sd*, probably you didnt pick correct OS type and that caused virtio associated driver not being loaded.
[root@vm ~]# fdisk -l /dev/vda
Disk /dev/vda: 21.5 GB, 21474836480 bytes
16 heads, 63 sectors/track, 41610 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0006fe0a
Device Boot Start End Blocks Id System
/dev/vda1 * 3 409 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2 409 41611 20765696 8e Linux LVM
Partition 2 does not end on cylinder boundary.
2011年12月2日 星期五
Garbage / Missing fonts in RHEL Virt-manager
Virt-Manager is a X application which is capable to manage RHEL's XEN,
QEMU/KVM, LXC service. Similar to other X application, it could be
launched remotely via X11 Forwarding.
[root@server ~]# yum -y install dejavu-lgc-sans-fonts
However, it
happens that garbage fonts will be shown if the host is not
installed with appropriate font package. To fix this, package
dejavu-lgc-sans-fonts have to be installed.
2011年11月21日 星期一
Disable X windows on Ubuntu 10.04
In CentOS / RHEL, people would change option on initdefault from /etc/inittab to control whether X11 should be started. In Ubuntu, it is totally different, there is no such iniitab file on Ubuntu. To stop Ubuntu to start X11 (i.e. behave more or less the same as runlevel 3 in CentOS), one have to modify the /etc/init/gdm.conf and edit the line to disable gdm service on runlevel 2.
Here is the line
Here is the line
# stop on runlevel [0126] ## This means GDM will start on run level 1, 2 and 6.
stop on runlevel [016] ## This means GDM will only start on run level 1 and 6. And Ubuntu's default run level is 2, i.e GDM wont start on default run level.
After that, a system reboot will bring your ubuntu installation to text mode.
stop on runlevel [016] ## This means GDM will only start on run level 1 and 6. And Ubuntu's default run level is 2, i.e GDM wont start on default run level.
After that, a system reboot will bring your ubuntu installation to text mode.
2011年11月20日 星期日
Recover corrupted LVM root partition by fsck
So you have a Linux machine that is installed with LVM and you have assigned root partition to sit on that LVM pool. One day your machine is crashed and the root partition is corrupted. It failed to boot properly and asked you to fill in root password to run fsck. Sadly, you lost the root password and you need a recovery CD (or installation CD) to boot and recover the disk.
Now your machine is booted and you found that your just couldn't run fsck against a LVM partition.
root@test:/# fdisk -l
Disk /dev/vda: 21.5 GB, 21474836480 bytes
16 heads, 63 sectors/track, 41610 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00014ef8
Device Boot Start End Blocks Id System
/dev/vda1 * 3 389 194560 83 Linux
/dev/vda2 391 41609 20773888 8e Linux LVM
So rescue CD by default just won't automatically activate the LVM (and its underlaying volumes). What you need to do is to activate the LVM partition. and then run fsck on the volumes.
### Run lvm from rescue CD
bash-4.1# lvm
### This will scan and list the PV
lvm> pvscan
PV /dev/vda2 VG volgroup01 lvm2 [19.78GiB/ 0 free]
Total: 1 [19.78 GiB] / in use: 1 [19.78 GiB] / in no VG: 0 [0 ]
### This will scan and list the VG
lvm> vgscan
Reading all physical volumes. This may take a while...
Found volume group "volgroup01" using metadata type lvm2
### This will list and scan the LV (the meat is here)
lvm> lvscan
inactive '/dev/volgroup01/root' [11.78 GiB] inherit
inactive '/dev/volgroup01/swap' [8.00 GiB] inherit
### And then execute lvchange
bash-4.1# lvchange -ay /dev/volgroup01/root
### So quit the lvm
lvm > exit
Adding dirhash hint to filesystem
### now time to run fsck
bash-4.1# fsck -y /dev/volgroup01/root
Now your machine is booted and you found that your just couldn't run fsck against a LVM partition.
root@test:/# fdisk -l
Disk /dev/vda: 21.5 GB, 21474836480 bytes
16 heads, 63 sectors/track, 41610 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00014ef8
Device Boot Start End Blocks Id System
/dev/vda1 * 3 389 194560 83 Linux
/dev/vda2 391 41609 20773888 8e Linux LVM
So rescue CD by default just won't automatically activate the LVM (and its underlaying volumes). What you need to do is to activate the LVM partition. and then run fsck on the volumes.
### Run lvm from rescue CD
bash-4.1# lvm
### This will scan and list the PV
lvm> pvscan
PV /dev/vda2 VG volgroup01 lvm2 [19.78GiB/ 0 free]
Total: 1 [19.78 GiB] / in use: 1 [19.78 GiB] / in no VG: 0 [0 ]
### This will scan and list the VG
lvm> vgscan
Reading all physical volumes. This may take a while...
Found volume group "volgroup01" using metadata type lvm2
### This will list and scan the LV (the meat is here)
lvm> lvscan
inactive '/dev/volgroup01/root' [11.78 GiB] inherit
inactive '/dev/volgroup01/swap' [8.00 GiB] inherit
### And then execute lvchange
bash-4.1# lvchange -ay /dev/volgroup01/root
### So quit the lvm
lvm > exit
Adding dirhash hint to filesystem
### now time to run fsck
bash-4.1# fsck -y /dev/volgroup01/root
2011年11月17日 星期四
Install QEMU-KVM in RHEL / CentOS
Here is the command to install QEMU-KVM packages in RHEL / CentOS,
yum -y install qemu-kvm qemu-kvm-tools libvirt
or these command will install the packages for associated virtualization stuff.
yum -y groupinstall "Virtualization"
yum -y groupinstall "Virtualization Client"
yum -y groupinstall "Virtualization Platform"
yum -y groupinstall "Virtualization Tools"
yum -y install qemu-kvm qemu-kvm-tools libvirt
or these command will install the packages for associated virtualization stuff.
yum -y groupinstall "Virtualization"
yum -y groupinstall "Virtualization Client"
yum -y groupinstall "Virtualization Platform"
yum -y groupinstall "Virtualization Tools"
2011年11月14日 星期一
Bandwidth testing with iperf
To test bandwidth between 2 linux servers, we would use a tools call iperf. Installing iperf from repository is easy, what we need to run is
[root@server ~]# yum -y install server.
Or,
You may want to run apt-get install iperf on debian or ubuntu.
Once we install the package on both machines, we will need to pick one node to run as server
[root@server ~]# iperf -s
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
Once service is running, we could run iperf from the client machine to connect to server.
[root@client ~]# iperf -c 192.168.0.1
------------------------------------------------------------
Client connecting to 192.168.0.1, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[ 3] local 192.168.0.2 port 37476 connected with 192.168.0.1 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 1.38 GBytes 1.19 Gbits/sec
Now the bandwidth is 1.19Gbit/sec, which is pretty much correct on my VM.
There are some other common options could be used. For e.g. using -d would perform a bi-directional test, i.e testing the bandwidth from source-to-target and then target-to-source. Using -n $some_number would define the size to transfer.
Below example will send approximately 1000Mb of data to test.
[root@client ~]# iperf -n 1000000000 -c 192.168.0.1
------------------------------------------------------------
Client connecting to 192.168.0.1, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[ 3] local 192.168.0.2 port 39375 connected with 192.168.0.1 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 7.8 sec 954 MBytes 1.03 Gbits/sec
[root@server ~]# yum -y install server.
Or,
You may want to run apt-get install iperf on debian or ubuntu.
Once we install the package on both machines, we will need to pick one node to run as server
[root@server ~]# iperf -s
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
Once service is running, we could run iperf from the client machine to connect to server.
[root@client ~]# iperf -c 192.168.0.1
------------------------------------------------------------
Client connecting to 192.168.0.1, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[ 3] local 192.168.0.2 port 37476 connected with 192.168.0.1 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 1.38 GBytes 1.19 Gbits/sec
Now the bandwidth is 1.19Gbit/sec, which is pretty much correct on my VM.
There are some other common options could be used. For e.g. using -d would perform a bi-directional test, i.e testing the bandwidth from source-to-target and then target-to-source. Using -n $some_number would define the size to transfer.
Below example will send approximately 1000Mb of data to test.
[root@client ~]# iperf -n 1000000000 -c 192.168.0.1
------------------------------------------------------------
Client connecting to 192.168.0.1, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[ 3] local 192.168.0.2 port 39375 connected with 192.168.0.1 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 7.8 sec 954 MBytes 1.03 Gbits/sec
訂閱:
文章 (Atom)