Tech/Openstack

LINUX TARBALL을 통해 glance image를 생성하기

타이호 2017. 12. 22. 19:42
반응형

리눅스 이미지가 img나 iso로 되어 있는 이미지도 있지만 압축된 tarball 형태로 구성된 이미지도 배포를 하고 있다.

해당 tarball을 통해 glance에 이미지를 어떻게 생성하는지는 아래와 같이 수행하면 된다


# download a tar file of a root file system

wget https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-root.tar.gz


# create a backing file and a loopback device to it

truncate --size 2GB trusty.img

sudo losetup -f trusty.img


# find what /dev/loopX was used - it was /dev/loop1 this time

sudo losetup -a


# write out a filesystem and mount it

sudo mkfs /dev/loop0

mkdir mnt

sudo mount /dev/loop0 mnt


# extract the root fs tar into the image file

cd mnt

sudo tar -xvf ../trusty-server-cloudimg-amd64-root.tar.gz


cd ../

sudo umount /dev/loop0


glance image-create --name trusty-rootfs --is-public True \

 --disk-format raw --container-format bare \

 --progress --file trusty.img

반응형