[Solved] Raw.idmap working partially

Hello,

I would like to use the host uid/gid 140:140 in an alpine image. This uid/gid is for mysql. On the host i have

$ cat /etc/subuid
root:1000000:65536
root:140:1
$ cat /etc/subgid
root:1000000:65536
root:140:1

In the lxc container i have defined,

raw.idmap: both 140 140
devices:
  sharedb:
    path: /var/lib/mysql
    source: /var/lib/mysql
    type: disk

The host lists the files as:

# ls -l /var/lib/mysql
total 528
-rw-rw---- 1 mysql mysql   24576 Apr  1 09:36 aria_log.00000001
-rw-rw---- 1 mysql mysql      52 Apr  1 09:36 aria_log_control
drwxr-xr-x 2 mysql mysql       3 Mar 30 05:26 innodb
drwxr-xr-x 2 mysql mysql       4 Mar 30 05:58 logs
-rw-rw---- 1 mysql mysql       0 Dec 17 01:28 multi-master.info
drwx------ 2 mysql mysql      89 Mar 30 07:44 mysql
-rw-rw---- 1 mysql mysql       0 Apr  1 09:31 mysql-bin.index
-rw-rw---- 1 mysql mysql 2119122 Dec 17 01:32 mysqld-bin.000001
-rw-rw---- 1 mysql mysql      20 Dec 17 01:30 mysqld-bin.index
-rw-rw---- 1 mysql mysql       9 Dec 17 01:32 mysqld-bin.state
drwx------ 2 mysql mysql     309 Mar 30 07:51 mythconverg
drwx------ 2 mysql mysql       3 Dec 17 01:28 performance_schema
drwx------ 2 mysql mysql       2 Dec 17 01:27 test

However in the container the logs and innodb folder still have ‘nobody:nobody’ set instead of mysql.

# ls -la /var/lib/mysql/
total 537
drwxr-xr-x   10 mysql    mysql           17 Apr  1 09:33 .
drwxr-xr-x    6 root     root             6 Apr  1 03:37 ..
-rw-rw----    1 mysql    mysql        24576 Apr  1 09:36 aria_log.00000001
-rw-rw----    1 mysql    mysql           52 Apr  1 09:36 aria_log_control
drwxr-xr-x    2 nobody   nobody           2 Mar 30 07:04 innodb
drwxr-xr-x    2 nobody   nobody           2 Mar 30 11:07 logs
-rw-rw----    1 mysql    mysql            0 Dec 17 01:28 multi-master.info
drwx------    2 mysql    mysql           89 Mar 30 07:44 mysql
-rw-rw----    1 mysql    mysql            0 Apr  1 09:31 mysql-bin.index
-rw-rw----    1 mysql    mysql      2119122 Dec 17 01:32 mysqld-bin.000001
-rw-rw----    1 mysql    mysql           20 Dec 17 01:30 mysqld-bin.index
-rw-rw----    1 mysql    mysql            9 Dec 17 01:32 mysqld-bin.state
drwx------    2 mysql    mysql          309 Mar 30 07:51 mythconverg
drwx------    2 mysql    mysql            3 Dec 17 01:28 performance_schema
drwx------    2 mysql    mysql            2 Dec 17 01:27 test

All the other directories have uid/gid of mysql except innodb and logs!. Any idea why is that?

Mysql config my.cnf in the container is,

# cat /etc/mysql/my.cnf

[client]
port            = 3306
socket          = /run/mysqld/mysqld.sock

[mysqld]
port            = 3306
socket          = /run/mysqld/mysqld.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 200M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
bind-address                            = 0.0.0.0
log-bin=mysql-bin
binlog_format=mixed

server-id       = 1

innodb_buffer_pool_size = 20G

innodb_data_home_dir            = /var/lib/mysql/innodb
innodb_data_file_path = ibdata1:10M:autoextend:max:128M
innodb_log_group_home_dir       = /var/lib/mysql/logs

innodb_data_file_path = ibdata1:10M:autoextend:max:15G
innodb_log_file_size = 256M
innodb_log_buffer_size = 16M
innodb_log_files_in_group=2
innodb_flush_log_at_trx_commit = 2
innodb_lock_wait_timeout = 50
innodb_write_io_threads         = 8
innodb_read_io_threads          = 8
innodb_autoinc_lock_mode        = 2
innodb_file_per_table=off
skip-innodb_doublewrite

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

The innodb and logs were separate ZFS datasets. I had to share them individually,

 devices:
  sharedb:
    path: /var/lib/mysql
    source: /var/lib/mysql
    type: disk
  sharedb1:
    path: /var/lib/mysql/innodb
    source: /var/lib/mysql/innodb
    type: disk
  sharedb2:
    path: /var/lib/mysql/logs
    source: /var/lib/mysql/logs
    type: disk

You could get away with just the first one but with recursive: true set on it, that should then bring in the other two for you.

1 Like

Hello

I have the same issue with LXD 3.6.
I need to mount from host to container /srv/shared and /srv/shared/video points

Before LXD 3.6 I have been using following config:
devices:
shared:
path: srv/shared
source: /srv/shared
recursive: “true”
type: disk

Now in LXD 3.6 I have to mount it manually:
devices:
video:
path: srv/shared/video
source: /srv/shared/video
type: disk
shared:
path: srv/shared
source: /srv/shared
type: disk

Do you know how to avoid it?

Thanks in advance