Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Jun 052011
 

Create a swap partition using LVM

Answer:

To create a swap partition using LVM, you just need a few commands!

1. Create a 1G swap partition

# lvcreate -L 1G -n /dev/vg0/swap0

2. Set up a Linux swap partition

# mkswap /dev/vg0/swap0

3. Enable it

# swapon -s /dev/vg0/swap0

You might also want to put the settings in the /etc/fstab, so it will be mounted automatically when your system boot next time.

# sudo vi /etc/fstab

/dev/vg0/swap0       none            swap     sw              0       0

Save and restart your system to test if it is working when system reboot.

May 202011
 

Create a new ext3 file system using LVM

Answer:

To create a new ext3 partition using the Logical Volume Manager (LVM) is just easy with a few commands:

# lvcreate -L 100G -n /dev/vg0/vp0 (Assume volume group is vg0) 
# mkfs -t ext3 -m 1 -v /dev/vg0/vp0

Then you can mount the /dev/vg0/vp0 as usual.

Jul 222010
 

Display attributes of a logical volume under LVM

Answer:

If you are using LVM, you can easily display attributes of a logical volume using the command lvmdisplay

# sudo /usr/sbin/lvdisplay

  /dev/sdb: read failed after 0 of 2048 at 0: Input/output error
  /dev/sdb1: read failed after 0 of 2048 at 0: Input/output error
  /dev/sdb2: read failed after 0 of 2048 at 0: Input/output error
  /dev/sdb3: read failed after 0 of 2048 at 0: Input/output error
  --- Logical volume ---
  LV Name                /dev/vg0/d148
  VG Name                vg0
  LV UUID                JhG2hr-lnyx-yT2h-rUMN-7tuP-yW0j-rQ1YSu
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                80.00 GB
  Current LE             20480
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0