Linux mount persistent memory (PMEM)

Mount persistent memory (PMEM)

1. Install virtual machine (bridge network mode)

  1. Select [typical (recommended)] to proceed to the next step

  2. Select the installation operation later and click next

  3. Select [client operating system - Linux, version CentOS 7 64 bit], next

  4. Virtual machine naming, next step

  5. [maximum disk size - 60G, split the virtual disk into multiple files] (note that the disk size is not easy to be too small for kernel experiments)

  6. [custom hardware]

  7. [memory - 4GB]

  8. [number of processors - 2, number of cores - 2], check [virtualization Intel VT-x/EPT or AMD-V/RVI]

  9. Use the ISO image file to locate the downloaded ISO file of CentOS

  10. Network adapter select bridge mode

  11. Click close to finish the final configuration preview, and click finish

  12. Start the virtual machine and click enter

  13. Select Chinese for configuration text

  14. Configure [software selection], select [server with GUI], and [finish] in the upper left corner

  15. Configuration [installation location]

  16. Select [I want to configure partition] and [finish] in the upper left corner

  17. Select [standard partition] and click [+] to add the mount point (note that the experiment of compiling the kernel should not add too small memory to / boot)


  18. Finish, accept changes

  19. Start installation (set root password, create user)

  20. Configure bridge network

    1. Configuration Bridge

      vi /etc/sysconfig/network-scripts/ifcfg-cloudbr0
      

      Insert:

      #[ifcfg-cloudbr0], there was no such file originally
      DEVICE=cloudbr0
      TYPE=Bridge
      ONBOOT=yes
      BOOTPROTO=static
      IPV6INIT=no
      IPV6_AUTOCONF=no
      DELAY=5
      IPADDR=192.168.1.2[Of the same network segment as the host ip Address]
      GATEWAY=192.168.1.1[gateway xxx.xxx.xxx.1]
      NETMASK=255.255.255.0
      DNS1=8.8.8.8
      DNS2=8.8.4.4
      STP=yes
      USERCTL=no
      NM_CONTROLLED=no
      # Remember to delete these comments
      
    2. Modify network configuration

      vi /etc/sysconfig/network-scripts/ifcfg-ens33.
      

      Amend to read:

      TYPE=Ethernet
      PROXY_METHOD=none
      BROWSER_ONLY=no
      BOOTPROTO=none
      DEFROUTE=yes
      IPV4_FAILURE_FATAL=no
      IPV6INIT=no
      IPV6_AUTOCONF=no
      IPV6_DEFROUTE=no
      IPV6_FAILURE_FATAL=no
      IPV6_ADDR_GEN_MODE=stable-privacy
      NAME=ens33
      UUID=522f2028-1e48-421b-9c25-aef00237719d
      DEVICE=ens33
      ONBOOT=yes
      BRIDGE=cloudbr0
      
    3. Restart the network

      chkconfig network on
      systemctl stop NetworkManager
      systemctl disable NetworkManager
      systemctl restart network
      

##2. Compile kernel enable PMEM module

  1. Download kernel

    The kernel can be downloaded through the official Linux website or through some domestic websites.

    Recommended kernel version: linux-4.16.10

    Compressed package after downloading: linux-4.16.10 tar. gz

  2. Unzip (unzip the compressed package to / usr/src directory)

    tar xf linux-4.16.10.tar.gz -C /usr/src
    
  3. Configure kernel

    cd linux-4.16.10
    

    Enter the extracted kernel version directory and execute the following command

    make menuconfig
    

    Note that some packages need to be installed before the command is executed (if a package is still missing, just install it according to the prompt)

    yum install gcc
    yum install ncurses ncurses-devel
    

    To enter the graphical configuration interface, you need to be able to PMEM module

    -> Device Drivers -> NVDIMM Support ->
    <M>PMEM; <M>BLK; <*>BTT
    //Adjust by space
    
    //Back to the home page
    -> Processor type and features
    <*>Support non-standard NVDIMMs and ADR protected memory
    
  4. Compile kernel

    make -j4
    //j4 means that four compilation commands are executed at the same time. j8 can be used on 4-core machines
    //Similarly, if any package is missing, install it according to the prompt
    
  5. Compiling and installing modules

    make modules
    make modules_install
    
  6. Modify grub file

    nano /etc/default/grub  
    

    Add as follows:

    memmap=nn[KMG]!ss[KMG] 
    #Allocate the memory area as PMEM, ss represents the starting memory address, and nn represents the area size, such as 4G!12G represents the memory range from 12G to 16G as PMEM [KMG] indicates KB,MB,GB The details are as follows:
    GRUB_CMDLINE_LINUX="memmap=4G!4G"
    
  7. Update grub file

    //CentOS instruction
    grub2-mkconfig -o /boot/grub2/grub.cfg
    //If the user is ubuntu
    update-grub2
    
  8. Restart the virtual machine

    reboot
    

    Select the corresponding compiled kernel system
    After restart, check the drive directory dev to see that PEME0 has been successfully mounted

    ls /dev
    

    Mount succeeded

3. Configure the persistent memory as a local disk

  1. Install persistent memory management tools

    yum install -y ndctl daxctl
    
  2. The configuration usage mode is fsdax

    ndctl create-namespace -f -e namespace0.0 --mode=fsdax
    
  3. Format and mount the disk

    mkfs -t ext4 /dev/pmem0 
    mount -o dax,noatime /dev/pmem0 /mnt
    
  4. View mounted disks

    df -h
    

    Configuration succeeded

  5. be careful
    Note that after the virtual machine is mounted, the mount information will be lost every time the virtual machine is shut down, and it needs to be mounted again after restart.

Tags: Linux

Posted by Kerry Kobashi on Fri, 15 Apr 2022 21:45:10 +0930