Monthly Archives: October 2013

linux – assign variables to a file or directory

setfattr -n user.name -v “Vitalijus” testdir
echo “some test” > testdir/testfile
setfattr -n user.test -v “Test file” testdir/testfile
getfattr -d -R testdir > xattr.attr

rm -rf testdir
mkdir testdir ; echo “xaxaxa” > testdir/testfile
setfattr –restore=xattr.attr
getfattr -d -R testdir

Extended attributes are properties organized in (name, value) pairs, optionally set to files or directories in order to record information which cannot be stored in the file itself. They are supported by operating system.

On Linux, specifically, four categories of extended attributes have been defined :

  • trusted : to record properties which should only be accessed by the kernel,
  • security : to record security properties of a file,
  • system : to record other system related properties on which the file owner has some control,
  • user : to record properties defined by applications.

ext4 features

ext4 uses extents, which improves performance when using large files and reduces metadata overhead for large files

faster fsck during boot (unallocated blocks are grouped)

file system features ( persistent pre-allocation, delayed, multi-block,  stripe-aware allocation)

xattr (user_xattr)

quota journaling

linux – inode

It is like a database of all file information except the file contents and the file name.  The inode entries store metadata about each file, directory or object, but only points to these structures rather than storing the data. Each entry is 128 bytes size.

  • Inode number
  • Mode information to discern file type and also for the stat C function
  • Number of links to the file
  • UID of the owner
  • Group ID (GID) of the owner
  • Size of the file
  • Actual number of blocks that the file uses
  • Time last modified
  • Time last accessed
  • Time last changed

LVM advantages disadvantages

LVM advantages:

  • Use any number of disks as one big disk.
  • Have logical volumes stretched over several disks.
  • Create small logical volumes and resize them “dynamically” as they get more filled.
  • Resize logical volumes regardless of their order on disk. It does not depend on the position of the LV within VG, there is no need to ensure surrounding available space.
  • Resize/create/delete logical and physical volumes online. Filesystems on them still need to be resized, but some support online resizing.
  • Online migration of LV being used by services to different disks without having to restart services.
  • Snapshots allow you to backup a frozen copy of the filesystem, while keeping service downtime to a minimum.

LVM disadvantages:

  • Linux exclusive (almost). There is no official support in most other OS (FreeBSD, Windows..).
  • Additional steps in setting up the system, more complicated.
  • If you use the btrfs filesystem, its Subvolume feature will also give you the benefit of having a flexible layout. In that case, using the additional Abstraction layer of LVM may be unnecessary.

I recommend use LVM, because of great power.

device-mapper: device /dev/vda2 too small for target – LVM

You can face this problem after trying to resize your logical volume partitions:

lvresize -L +2G /dev/mapper/VolGroup-lv_root
Extending logical volume lv_root to 10.07 GiB
device-mapper: resume ioctl on failed: Invalid argument
Unable to resume VolGroup-lv_root (253:0)
Problem reactivating lv_root

you can fix this booted from rescue image:

fdisk /dev/vda
d 2
n 2
old_start new_end
t 2
8e (Linux LVM)
w

then:
lvextend -l +100%FREE /dev/VolGroup/lv_root
lvmdiskscan