Boot Ubuntu in 19 Seconds
Want your Ubuntu to boot more quickly? Read this.
There are also links to solutions to the odd “resume” problems I was experiencing: “no resume image” on my swap partition.
Want your Ubuntu to boot more quickly? Read this.
There are also links to solutions to the odd “resume” problems I was experiencing: “no resume image” on my swap partition.
Here’s a great tip for copying files from your desktop to EC2 (or any remote Windows server). Posted on Amazon’s EC2 forum by P. Hebert:
“Before you connect to the instance, wander through the tabs and find check the box under “Local drives and resources” for your C: drive. Once connected to the instance, open Windows Explorer and in the address bar, type “tsclientc” (without quotes). your local PC’s C: drive will (slowly) open up in Explorer and you can drag&drop.”
“This doesn’t require any additional ports to be opened up; it goes over the RDP connection you already using for remote desktop. ”
While I understood the value of using UUIDs to specify devices in /etc/fstab, it wasn’t clear how it all worked. After a bit of googling …
When a device is connected, the system automatically retrieves its UUID, regardless of which interface is used. The list of currently available devices can be displayed with:
ls /dev/disk/by-uuid -lh
Currently available block device ids can be displayed using blkid and attributes of individual devices is displayed by vol_id /dev/name.
Also, blkid information is cached in /etc/blkid.tab.
Very important: if you clone drives with dd, the UUID will be cloned too! If this isn’t what you had in mind, reset it using:
tune2fs -U UUID /dev/name
where UUID is one of the following:
a unique id like “c1b9d5a2-f162-11cf-9ece-0020afc76f16”
or clear, random or time.
Long after Erlang set the standard for concurrent languages, Microsoft is addressing the issue with extensions to C++. Here are a couple of excellent articles from MSDN:
Design Considerations for Parallel Programming
and
A rather neat little piece of code I ran across for “human” sorting. Given an array of picture names:
%w[picture3 picture20 picture1004 picture1].sort_by {|item| item.scan(/[0-9]+|[^0-9]+/).map {|s| s[/[^0-9]/] ? s : s.to_i} }
Split each string up into runs of digits or runs of non-digits, convert the digit strings to integers, and sort array-wise (component by component).
Not clear why this is the case, but the WebDAV client in Explorer on XP has been somewhat broken for years.
Specifying a URL like this won’t work:
https://example.com/webdav
Instead you need to explicitly specify the port:
https://example.com:80/webdav
No idea why it works this way – perhaps someone at Microsoft can tell us.
To install fuse on CentOS:
yum install fuse dkms dkms-fuse modprobe fuse depmod
From G Garon at go2linux:
For security reasons it is not a good idea to permit ssh root direct login, it is better to login as another user, and then switch to root using the ‘su -‘ comand, to do this, you need to disable root from login directly using ssh protocol, this will decrease the possibility of a hacker breaking your linux box, as now he will have to guess your user name and your password
Ok, let’s go and see to make this.
Edit the file /etc/ssh/sshd_config
vi /etc/ssh/sshd_config
(you can use your favorite text editor)
I strongly recommend you to open two logins if doing this from a remote connection, and never close one of them, in case you need to roll back the configuration
locate this line with, writing this onces editing with vi or vim
:/Protocol
if it says
Protocol 2, 1
change it to:
Protocol 2
This will enable only ssh2 which is more secure that ssh, do not do this if you need to log with a client that only support ssh, and not ssh2 protocol.
Next locate this line “PermitRootLogin yes” by entering this on your vi or vim editor
:/PermitRootLogin yes
and change it to this:
PermitRootLogin no
and save the file, with this:
shift+zz
now restart the ssh service.
If Fedora or CentOS
/etc/init.d/sshd restart
If Debian or Ubuntu
/etc/init.d/ssh restart
Test that you can login and gain root access with ‘su -‘ (without quotes), before, you left your root remote connection
Related Links
https://linux.go2linux.org/node/6
https://linux.go2linux.org/taxonomy/term/3
Copied from JP Houde’s blog:
OK, so you downloaded an image from jailtime.org or you made your own image as described in my previous post, and now you want to install a Xen guest using it. Here’s how to do it :
Of course, Xen should be installed on the host OS. I use CentOS 5, so I just selected Xen during the installation. It will install a xen kernel that you should use to boot the host OS (dom0). I won’t go into details here, because that’s really easy to do with CentOS or Redhat Enterprise Linux. With other distributions, you could have to install distribution-specific packages, or use the official Xen package from xen.org.
You should create a filesystem for the “root” partition and the swap. You could use simple files, but you will have better performance using real partitions or LVM volumes. LVM volumes also has other advantages, like the ability to create snapshots for backing up data, and easy resizing.
The following commands will create a 5GB root logical volume (LV) and 1GB swap in the /dev/vg0 volume group (VG). For more information about LVM, search for LVM howto in a search engine.
# root lvcreate -L 5000M -n mailroot /dev/vg0 mkfs.ext3 /dev/vg0/mailroot # swap lvcreate -L 1000M -n mailswap /dev/vg0 mkswap /dev/vg0/mailswap
You can then mount the root partition and copy the base system (either an image from jailtime or an image you made yourself) on it.
mkdir /mnt/mailroot mount /dev/vg0/mailroot /mnt/mailroot # if you image contents is located in /centos... cp -R /centos/* /mnt/mailroot/
Don’t forget to unmount the root partition when you’re done! Xen will not boot the domain if the partition is already mounted.
The kernel that we will need to boot the domU has be to located in the dom0.
You can use the standard xen kernel that comes with CentOS to do that (e.g. vmlinuz-2.6.18-53.1.13.el5xen) , but you’ll also need an initrd, or the kernel won’t boot. To make the initrd, use the following command :
/sbin/mkinitrd --with=xennet --preload=xenblk /boot/initrd-centos5-xen.img 2.6.18-53.1.13.el5xen
This makes an initrd image with the required modules to boot a domU. The last parameter is the version of your kernel (the one you will use to boot the domU). You can get this number by typing “uname -r” on the command line. This will result in a /boot/initrd-centos5-xen.img image file.
Note (2008-02-14) : in a previous version of this blog post, I recommended to use a kernel from the official Xen distribution at xen.org. It worked, but it doesn’t seem to work anymore.
The configuration of the Xen guest is controlled by a simple text file. Create it as /etc/xen/yourdomUname, and move (or symlink) it in /etc/xen/auto if you want to start it automatically on boot.
Most basic parameters in this file are easy to understand. You should make sure “kernel” points to the kernel you copied from the xen tarball. “memory” is the amount of RAM allocated to the guest. “name” will be the name of the guest that you will use when connecting to it or shutting it down using the “xm” command.
“vif” contains information about network interfaces. One important thing in that line is the MAC address. If you don’t specify it here, a random MAC will be assigned at each boot, and that may not give good results. Edit the last 3 numbers (put anything, it just has to be unique across your network).
Finally, ‘disk’ is the parameter that tells Xen what partitions to use and what device name it will assign them. The last line, ‘root’, will tell the kernel what is the root device.
kernel = "/boot/vmlinuz-2.6.18-53.1.13.el5xen" ramdisk = "/boot/initrd-centos5-xen.img" memory = 512 name = "mail" vif = [ 'mac=00:16:3e:21:f1:31,bridge=xenbr0' ] dhcp = "dhcp" disk = ['phy:/dev/vg0/mailroot,sda1,w', 'phy:/dev/vg0/mailswap,sda2,w' ] # The next line would be useful if you want to use an simple file instead of a partition/LV #disk = ['file:/root/test.img,sda1,w', 'file:/root/centos.swap,sda2,w' ] # We don't use pygrub, we boot the kernel directly from dom0 #bootloader="/usr/bin/pygrub" root = "/dev/sda1 ro"
OK, you’re ready to boot the guest domain! Just issue the following command to “create” (which means boot, really) the domU.
xm create /etc/xen/YOUR_CONFIG_FILE -c
The -c parameter tells xm to connect to the domain’s console. You can disconnect from it by pressing CTRL+], and connect to it again with “xm connect NAME”.
If everything works right, you should see the login prompt appearing, and you will be ready to use the new guest domain!
If you made the guest image yourself as I explained in my previous post (part 1), you need to create the random device to fix SSH (and probably other services that requires generating keys). Issue the following commands on the guest’s console :
/sbin/MAKEDEV generic /etc/init.d/sshd start
Copied from JP Houde’s blog:
I recently needed to configure Xen guests on a CentOS server. I didn’t want to use CentOS/Redhat’s tool for several reasons : I don’t like the fact that it creates a “disk” with a whole partition table within the partition where you install it. Installing the guest directly on a LVM logical volume seems better to me (I may not be right, I’m still somewhat new to Xen!). Also, it was very instructive to do all the steps by myself rather than using a tool that does everything.
However, I had several problems while trying to install my first guest system, so it took me quite some time to find the right way to do it. I found a lot of documentation on the web, but nothing really described what I really wanted to do. So here we are, I decided to write a post describing what to do exactly to make a custom guest image and install it as a Xen domU.
In this first part, I will explain how to make an OS image of CentOS 5 that will be suited for Xen.
Jailtime.org offer Xen images for several operating systems, including CentOS 4 and 5. However, only 32-bit images are available. If 32-bit images are OK for you, I recommend that you use the jailtime images : it will be a lot easier.
A note about the jailtime.org CentOS image : I found that the console was not working on boot. The OS seemed to just hang after starting SSHD, but in fact, it was just that there was no console for Xen to connect to. If you have this problem, see the part about configuring the console in the “Custom CentOS 5 image” section of this article.
Since I wanted 64-bit domUs, I decided to make my own images. There are few things that need to be modified to make a standard CentOS installation work as a Xen domU. Here are the steps needed to make your own image with yum.
[main] cachedir=/var/cache/yum keepcache=1 debuglevel=2 logfile=/var/log/yum.log pkgpolicy=newest distroverpkg=redhat-release tolerant=1 exactarch=1 obsoletes=1 gpgcheck=1 plugins=1 metadata_expire=1800[base] name=CentOS-$releasever - Base mirrorlist=https://mirrorlist.centos.org/?release=5&arch=x86_64&repo=os gpgcheck=1 gpgkey=https://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5 #released updates [updates] name=CentOS-$releasever - Updates mirrorlist=https://mirrorlist.centos.org/?release=5&arch=x86_64&repo=updates gpgcheck=1 gpgkey=https://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5 #packages used/produced in the build but not released [addons] name=CentOS-$releasever - Addons mirrorlist=https://mirrorlist.centos.org/?release=5&arch=x86_64&repo=addons gpgcheck=1 gpgkey=https://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
yum -c /etc/yum-xen.conf --installroot=/centos -y groupinstall core --disablerepo=extras
Here, we disable the “extras” repository since we don’t need it, and the variables it contains will make yum fail. You may need to disabled other repositories if you have installed custom ones.
You should now have a base system in your /centos directory ! But that’s not all, we need to modify few things to make our system suitable as a Xen guest.
As said earlier, you should now chroot in the /centos directory for the next steps. If you don’t do that, you could end up modifying your host OS instead of the image.
# add a console for xen co:2345:respawn:/sbin/mingetty console # comment out the default TTYs #1:2345:respawn:/sbin/mingetty tty1 #2:2345:respawn:/sbin/mingetty tty2 #3:2345:respawn:/sbin/mingetty tty3 #4:2345:respawn:/sbin/mingetty tty4 #5:2345:respawn:/sbin/mingetty tty5 #6:2345:respawn:/sbin/mingetty tty6
# for 32 bit : mv /lib/tls /lib/tls.disabled # for 64 bit : mv /lib64/tls /lib64/tls.disabled
echo exit 0 > /sbin/hwclock
#/sbin/start_udev
UPDATE 2008-02-14 : It seems that it may be a good idea to leave udev enabled after all… I’m getting permissions problem on devices such as /dev/null without udev. Enabling it fix the problem, and does not seem to cause any other problem.
TYPE=Ethernet DEVICE=eth0 BOOTPROTO=static BROADCAST=192.168.0.255 IPADDR=192.168.0.13 IPV6ADDR= IPV6PREFIX= NETMASK=255.255.255.0 NETWORK=192.168.0.0 ONBOOT=yes
/etc/sysconfig/network
NETWORKING=yes HOSTNAME=myhost.l3i.ca GATEWAY=192.168.0.1
/etc/resolv.conf (DNS resolver)
nameserver 4.2.2.1 nameserver 4.2.2.2
pwconv passwd root
cat > /etc/fstab # This file is edited by fstab-sync - see 'man fstab-sync' for details /dev/sda1 / ext3 defaults 1 1 /dev/sda2 none swap sw 0 0 none /dev/pts devpts gid=5,mode=620 0 0 none /dev/shm tmpfs defaults 0 0 none /proc proc defaults 0 0 none /sys sysfs defaults 0 0 #(press CTRL+D to end "cat")
/sbin/chkconfig haldaemon off
/sbin/MAKEDEV generic /etc/init.d/sshd start
You now have an image ready to be used as a Xen guest! Be sure to keep a copy before using it as a domU, so when you need to install another guest, you will have an image ready for it and won’t need to repeat these steps all over again.
Here is a link to an image I made myself using this procedure. You can use it if you don’t want to make your own. It is a 64-bit CentOS 5 core system, and the root password is “zaqxsw”.
In part 2, I will explain how to install a Xen guest from this image. (coming soon!)
Recent Comments